【问题标题】:Ngnix Jsession changed redirection issueNginx 会话更改重定向问题
【发布时间】:2015-09-17 03:40:36
【问题描述】:

有一种设置,例如一个应用程序正在 www.xyz.com 上运行,并且有一份报告对 www.abc.com 上托管的应用程序进行了点击。

由于 IE8 上出现了奇怪的 CORS 问题,我们在 www.xyz.com 上进行了其余的访问,但实际上服务托管在 www.abc.com 上,因此在 ngnix 级别,我们正在重定向来自 www.xyz 的其余请求。 com 到 www.abc.com。

但是在使用 www.xzy.com 应用程序上的报告后,当我们转到另一个页面时,会话就会过期。 jsessionid 在使用 www.xyz.com 上的报告后更改。

提前致谢。

服务器 { 听 80; server_name www.xyz.com; 字符集 utf-8; 重写 ^(.*) https://$server_name$1 永久; } 服务器 { 听443; 开启ssl; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_certificate /etc/nginx/ssl.crt/server.crt; ssl_certificate_key /etc/nginx/ssl.key/server.key; server_name www.xyz.com; 错误日志/var/log/nginx/error.log; 字符集 utf-8; 地点 / { proxy_pass http://localhost:97; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header 主机 $http_host; client_max_body_size 10M; } 位置 /api/rest/b2b/v1/report/filters/program-summary { proxy_pass http://localhost:90/api/rest/b2b/v1/report/filters/program-summary; 代理重定向关闭; proxy_pass_request_headers 开启; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置/api/rest/b2b/v1/report/headers/grid/program-summary/DATAGRID { proxy_pass http://localhost:90/api/rest/b2b/v1/report/headers/grid/program-summary/DATAGRID; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置/api/rest/b2b/v1/report/headers/grid/program-summary/SALES_REP { proxy_pass http://localhost:90/api/rest/b2b/v1/report/headers/grid/program-summary/SALES_REP; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/report/filters/variable/program-summary { proxy_pass http://localhost:90/api/rest/b2b/v1/report/filters/variable/program-summary; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/query/program-summary/barchart { proxy_pass http://localhost:90/api/rest/b2b/v1/query/program-summary/barchart; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/query/program-summary/datagrid { proxy_pass http://localhost:90/api/rest/b2b/v1/query/program-summary/datagrid; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/query/program-summary/status_pie { proxy_pass http://localhost:90/api/rest/b2b/v1/query/program-summary/status_pie; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; proxy_set_header X-Forwarded-Proto https; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/query/program-summary/summary { proxy_pass http://localhost:90/api/rest/b2b/v1/query/program-summary/summary; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v1/query/program-summary/sales_datagrid { proxy_pass http://localhost:90/api/rest/b2b/v1/query/program-summary/sales_datagrid; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,origin,authorization,accept,client-security-token'; } 位置 /api/rest/b2b/v2/constants/CDN_URL { proxy_pass http://localhost:90/api/rest/b2b/v2/constants/CDN_URL; 代理重定向关闭; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_request_headers 开启; proxy_set_header 主机 $http_host; client_max_body_size 10M; } 位置 ~ ^/templates/(.*)$ { 别名 /webroot/reporting-dashboard/templates/$1; } 位置 ~ ^/data/(.*)$ { 别名 /webroot/reporting-dashboard/data/$1; } 位置 ~ ^/styles/(.*)$ { 别名 /webroot/reporting-dashboard/styles/$1; } 位置 ~ ^/bower_components/(.*)$ { 别名 /webroot/reporting-dashboard/bower_components/$1; } 位置 /scripts/62219e5b.vendor.js { 别名/webroot/reporting-dashboard/scripts/62219e5b.vendor.js; } 位置 /scripts/9ec589bc.plugins.js { 别名/webroot/reporting-dashboard/scripts/9ec589bc.plugins.js; } 位置 /scripts/e13d4652.main.js { 别名/webroot/reporting-dashboard/scripts/e13d4652.main.js; } error_page 502 503 504 /vzb_50x.html; 位置 = /vzb_50x.html { 根 /tomcats/webapps/ROOT/static/errorFiles; } }

【问题讨论】:

  • 你是否在使用任何负载均衡器,比如 haproxy。你的会话不是持久性。我猜
  • 不在开发环境中。但是在生产中是的。
  • 您能否提供您的 nginx 配置,因为如果您使用会话 ID,问题似乎与此相同。
  • @thinkingmonster。我认为这是因为 JSESSION 被 www.abc.com 应用程序覆盖了。我如何删除/清除 nginx 中的 cookie?
  • ,试试这个链接github.com/openresty/headers-more-nginx-module..,Test定义的配置,让我知道结果。希望你能做提到的小改动。

标签: nginx


【解决方案1】:

在conf文件中添加proxy_hide_header Set-Cookie;解决了这个问题。这基本上从响应中删除了 cookie。

https://serverfault.com/questions/641417/nginx-not-processing-proxy-hide-header-and-proxy-ignore-headers

【讨论】:

  • @Mukesh 看来您已经找到了解决问题的方法。能否将问题标记为已结束。
猜你喜欢
  • 1970-01-01
  • 2018-03-29
  • 2011-06-26
  • 2011-10-20
  • 2012-12-04
  • 1970-01-01
  • 2014-06-13
  • 1970-01-01
  • 2013-01-28
相关资源
最近更新 更多