dqlk31541 2019-06-28 13:16
浏览 164

结合两个代理服务器的set-cookie头

We set up a nginx reverse proxy to handle request going to our app server. If a page is not found on the app server, the server returns a 404 and we send the request to our cms server, looking there for the page. This setup works so far, but we have problems when both proxied servers (app and cms) send a "Set-Cookie" header in the response, when the page is not found on the app server. Only the cookies from the cms server are send to the client.

Is it even possible to combine the "Set-Cookie" headers of both proxied servers? And if so, how is it done?

Our thoughts were to send the set-cookie response headers from the app server to the cms server and then and them there to the other cookies that are send to the client.

proxy_set_header App-Cookies $http_set_cookie;

But the set-cookie headers are not passed to the cms server.

server {
    listen 443;

    ...

    location / {

        proxy_pass http://app;
        proxy_pass_header Set-Cookie;
        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-Proto https;

        proxy_connect_timeout       120;
        proxy_send_timeout          120;
        proxy_read_timeout          120;
        send_timeout                120;

        error_page   404  = @cms;

        proxy_intercept_errors on;

    }

    location @cms {

        proxy_pass http://cms;
        proxy_pass_header Set-Cookie;
        proxy_set_header Host $host:8081;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Scheme on;

        # not working
        proxy_set_header App-Cookies $http_set_cookie;

        proxy_redirect http:// $scheme://;

   }

}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题