1.安装 nginx
2.在springboot项目配置文件中设置context-path 如图
3.在nginx 中conf文件下vim nginx.conf
# HTTPS server
#
server {
listen 443 ssl;
server_name www.;//域名
ssl_certificate cert.crt;//域名证书
ssl_certificate_key cert.key;//密钥
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /usr/local/dist/;//自己页面地址
index index.html index.htm;
}
location /back/{ // 路径记得与项目context-path配置一直
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8104;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
4.保存退出
5. 重启nginx: nginx -s reload