How to rewrite the domain part of Set-Cookie in a nginx reverse proxy?
Posted
by
Tobia
on Server Fault
See other posts from Server Fault
or by Tobia
Published on 2011-06-08T11:06:12Z
Indexed on
2012/04/14
23:33 UTC
Read the original article
Hit count: 264
I have a simple nginx reverse proxy:
server {
server_name external.domain.com;
location / {
proxy_pass http://backend.int/;
}
}
The problem is that Set-Cookie
response headers contain ;Domain=backend.int
, because the backend does not know it is being reverse proxied.
How can I make nginx rewrite the content of the Set-Cookie
response headers, replacing ;Domain=backend.int
with ;Domain=external.domain.com
?
Passing the Host
header unchanged is not an option in this case.
Apache httpd has had this feature for a while, see ProxyPassReverseCookieDomain
, but I cannot seem to find a way to do the same in nginx.
© Server Fault or respective owner