nginx http to https
server {
listen 80;
server_name xxx.cn www.xxx.cn;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name xxx.cn www.xxx.cn;
root /var/www/wwwroot/xxx/web;#vue项目的打包后的dist
ssl_certificate /var/www/ssl/xxx/cert.pem;
ssl_certificate_key /var/www/ssl/xxx/cert.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
location @router {
rewrite ^.*$ /index.html last;
}
}