Rewriting the domain part of Set-Cookie in a proxy_pass

António P. P. Almeida appa at perusio.net
Wed Jun 8 17:34:52 MSD 2011


On 8 Jun 2011 14h16 WEST, nginx-forum at nginx.us wrote:

> Hello
>
> Does nginx (or a module) provide functionality equivalent to httpd's
> ProxyPassReverseCookieDomain?
>
> Long explanation: 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. Therefore the users' browsers dutifully reject such
> bad cookies.
>
> How can I rewrite the content of the Set-Cookie response headers,
> replacing ";Domain=backend.int" with ";Domain=external.domain.com"?

AFAIK you'll need to use 3rd party modules. Either
http://wiki.nginx.org/HttpHeadersMoreModule and/or
http://github.com/chaoslawful/lua-nginx-module

Probably the Embedded Perl module let's you do that also. You'll have to
try it out.

--- appa




More information about the nginx mailing list