Problem: domains are stripped from the set-cookie
header.
httpoonly
, expires
, and path
are all correct.
My location block:
location ~* ^/path {
proxy_pass http://nodeserver; # this is an upstream running in another container
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 $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
curl foo.bar.local/path -X GET -I
-- this is hitting NGINX.set-cookie
headers come through, but without adomain
.curl localhost/path -X GET -I
-- hitting NGINX, but underlocalhost
instead of the domain, does not work.curl localhost:4010/path -X GET -I
-- directly hitting the (Node) server, cookie has correctdomain
.Adding something like
proxy_cookie_domain ~.*$ $http_host;
doesn't seem to have any effect.- Adding a
proxy_cookie_domain ~*.$ foo.bar.local
doesn't work. - With
add_header Set-Cookie "foo=bar; path=/; domain=$http_host";
the domain is set correctly. - Adding
proxy_cookie_path ~.*$ /foobar;
works as expected (cookies are rewritten to have path/foobar
).
Rewriting the set-cookie headers in perl or lua would probably work, but that seems like the wrong solution.