根据注释提示去修改就可以,证书需要到阿里云域名管理中申请下载(具体可以直接百度操作步骤)
server {
listen 80;
server_name www.xxxxxx.com ; # www.xxxxxx.com替换域名或ip,多个使用空格分开
return 301 https://$host$request_uri; # 将 HTTP 请求重定向到 HTTPS
access_log /www/wwwlogs/access.log; # 访问日志路径
}
server {
listen 443 ssl;
server_name www.xxxxxx.com ; # www.xxxxxx.com替换域名或ip,多个使用空格分开
ssl_certificate /etc/nginx/ssl/证书pem.pem; # 替换为你的 .pem 文件路径
ssl_certificate_key /etc/nginx/ssl/证书key.key; # 替换为你的 .key 文件路径
ssl_protocols TLSv1.2 TLSv1.3; # 启用的 SSL 协议
ssl_ciphers HIGH:!aNULL:!MD5; # 使用的加密套件
index index.html index.htm index.php; # 默认索引文件
location / {
root /www/server/nginx/data/dist; # 网站根目录
index index.html; # 默认索引文件
}
location /api {
proxy_set_header Host $http_host; # 设置主机头
proxy_set_header X-Real-IP $remote_addr; # 设置真实 IP
proxy_set_header REMOTE-HOST $remote_addr; # 设置远程主机
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置转发的 IP
proxy_pass http://localhost:6159/fortune; # 代理到后端服务
}
location /urlApi {
proxy_set_header Host $http_host; # 设置主机头
proxy_set_header X-Real-IP $remote_addr; # 设置真实 IP
proxy_set_header REMOTE-HOST $remote_addr; # 设置远程主机
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置转发的 IP
proxy_pass http://localhost:6159/; # 代理到后端服务
}
}
更新完配置文件需要重载一下nginx配置
一定需要先执行:
nginx -t
如果响应Successful了,否则就是配置文件有误,重新检查配置文件
再执行:
nginx -s reload