Rewriting the domain part of Set-Cookie in a proxy_pass

agentzh agentzh at gmail.com
Wed Sep 14 09:24:16 UTC 2011


On Wed, Sep 14, 2011 at 4:49 PM, agentzh <agentzh at gmail.com> wrote:
>    server_name external.domain.com;
>
>    location / {
>        proxy_pass http://backend.int/;
>
>        header_filter_by_lua '
>            local cookies = ngx.header.set_cookie
>            if not cookies then return end

Sorry, one line of Lua should be inserted right here for the case of a
single Set-Cookie response header:

            if type(cookies) ~= "table" then cookies = {cookies} end

that is, ngx.header.set_cookie will just return a single Lua string
instead of a Lua table if there's only one Set-Cookie header.

Regards,
-agentzh



More information about the nginx mailing list