nginx session 丢失解决

今天配置一个新项目,nginx 反向代理java,验证码总是不通过,查询发现是session丢失,nginx 文档:

Sets a text that should be changed in the path attribute of the “Set-Cookie” header fields of a proxied server response. Suppose a proxied server returned the “Set-Cookie” header field with the attribute “path=/two/some/uri/”. The directive
proxy_cookie_path /two/ /;

修改项目配置:

 location /ckl {
                proxy_pass  http://localhost:8080/ckl/;
                proxy_cookie_path /ckl /; #增加此行
                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_redirect     off; 
                proxy_read_timeout  60s;
                proxy_connect_timeout   60s;
                proxy_send_timeout   60s;
                proxy_set_header X-Forwarded-Proto https;
                proxy_intercept_errors on;
        }

重启nginx 解决

猜你喜欢

转载自blog.51cto.com/ckl893/2110936
今日推荐