千万别忘了开443端口
我这里使用的是阿里云的免费ssl
server {
listen 443 ssl;
server_name www.xxx.com;
#ssl on;
ssl_certificate /usr/local/nginx/cert/alivecaren.pem;
ssl_certificate_key /usr/local/nginx/cert/alivecaren.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ /index.html;
root /usr/local/nginx/vue;
index index.html index.htm;
}
location /api/{
proxy_pass http://localhost:8080/;
}
}
server {
listen 80;
server_name www.xxx.com;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
index index.html index.htm;
}
}