Cookies after NGINX reverse proxy Cookies after NGINX reverse proxy nginx nginx

Cookies after NGINX reverse proxy


(1) There is difference between redirection and proxying. The former is when a server issues a special HTTP status along with a new resource location and a browser makes a new request to the new location. So the browser here makes two requests. The latter is when your server forwards a request to another server. And from the browser's point of view it appears as if the original server returns the response.

So, according to your source code fragment, you are doing proxying.

(2) Cookies belong to domains. When a browser makes a request to new_domain.com, it will not send cookies that were set by main_domain.com, because the browser makes only one request to new_comain.com, because you are doing proxying, not redirect.


I think I answered your question "why". I do not know "how to fix", because something is seriously off with your approach and I have no idea what tradeoffs are possible or what changes are affordable.