nginx配置后通过http可以访问,https不能访问,在阿里云做的证书,审核都已通过,证书文件也已经添加了,重启nginx也没有报错。
这个是因为vue写的单页应用路由的关系要加上。
location / {
try_files $uri $uri/ /index.html;
}
下面是现在的nginx配置,
server {
listen 80;
root /www/cms/production/current/dist;
index index.html;
server_name cms.xmxmxm.me;
location / {
try_files $uri $uri/ /index.html;
}
}
server {
listen 443;
server_name cms.xmxmxm.me;
ssl on;
root /www/cms/production/current/dist;
index index.html index.htm;
ssl_certificate cert/214165781360223.pem;
ssl_certificate_key cert/214165781360223.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 / {
try_files $uri $uri/ /index.html;
}
location /ms/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
}
}