Linux的Nginx目录一般在etc/nginx
新建证书存放目录
sudo mkdir cert
sudo chmod 777 cert
拷贝文件到cert
7301250_abc.cn.key
7301250_abc.cn.pem
进入./sites-enabled/目录
新建配置文件
sudo touch abc.cn
sudo chmod 777 abc.cn
vim abc.cn
复制粘贴配置
server { listen 443; server_name abc.cn; ssl on; ssl_certificate cert/7301250_abc.cn.pem; ssl_certificate_key cert/7301250_abc.cn.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /home/web/; index index.html index.htm; #支持history模式 try_files $uri $uri/ /index.html; } location /api { proxy_pass http://127.0.0.1:8215/api; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; # 支持websocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
重启nginx
sudo service nginx restart