赞
踩
server {
listen 80;
server_name www.域名.com;
rewrite ^(.*) https:
//$server_name$1 permanent;
}
server {
listen 443;
server_name www.域名.com;
root /home/www;
ssl on;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
}
2、非80、443接口
加粗黑体字为关键ssl认证代码
server {
listen 2019 ssl;
server_name xk.thinkhub.com.cn;
ssl on;
ssl_certificate cert/2698782_xk.thinkhub.com.cn.pem;
ssl_certificate_key cert/2698782_xk.thinkhub.com.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;
#charset koi8-r;
#access_log logs/host.access.log main;
root D:/XinKang/rehabilitation/rmyy/dist; #vue项目的打包后的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
参考文献
https://blog.csdn.net/weixin_44316575/article/details/85328224
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。