配置443端口
server{
#监听443端口
listen 443;
#域名
server_name www.baidu.com;
ssl on;
#证书crt文件路径
ssl_certificate /www/server/panel/vhost/nginx/1_baidu.com_bundle.crt;
#证书key文件路径
ssl_certificate_key /www/server/panel/vhost/nginx/2_baidu.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#前端项目
location / {
root /home/pro;
index index.html;
try_files $uri $uri/ /index.html;
}
#后端接口
location /pro {
proxy_pass http://127.0.0.1:8889;
}
#静态文件
location /images {
alias /home/images/; # 文件存放目录要以 '/' 结尾;
index index.html;
autoindex on; # 自动列出目录下的文件;
autoindex_exact_size off; # 文件大小按 G、M 的格式显示;
}
}
配置80端口
#监听80端口转发到443端口
server{
listen 80;
#域名和上面相同
server_name www.baidu.com;
#修改其中的域名
rewrite ^/(.*)$ https://www.baidu.com:443/$1 permanent;
}
设置完成后,使用nginx -t 检查配置是否有语法错误,而后进行重启nginx就完成啦。

4594

被折叠的 条评论
为什么被折叠?



