前言
利用Django开发的一个小项目,想上线。配好于域名后,通过域名访问报错。最后确定是nginx反向代理配置的问题。
nginx配置
proxy_cookie_path导致的问题,下面的配置意思是将所有cookie路径更改为代理服务器的根路径。
upstream backend {
server 172.24.44.201:801 weight=1 fail_timeout=10s max_fails=1;
}
server {
listen 80;
server_name abm.webzhan.xyz;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
location / {
proxy_pass http://backend;
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";
}
}
评论 (0)