前言
前一段时间 人生模拟器 比较火,github上到目前为止9.3k的star。在自己的博客上也部署一个玩玩。顺便调试下nginx关于反向代理去掉路径的配置方法。
部署
获取代码
git clone https://github.com/VickScarlet/lifeRestart.git liferestart
使用docker启动
life:
build:
context: ./app2/liferestart/
dockerfile: Dockerfile
restart: always
ports:
- "8087:8080"
networks:
- myblog-net
前端nginx代理配置
# 新增配置
location /liferestart/ {
rewrite "^/liferestart/(.*)$" /$1 break;
proxy_pass http://172.17.0.10:8087;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cookie_path / "/; httponly; secure; SameSite=Lax";
proxy_redirect http:// https://;
add_header Content-Security-Policy upgrade-insecure-requests;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE';
add_header 'Access-Control-Allow-Header' 'Content-Type,*';
}
评论 (0)