proxy_cookie_domain
The proxy_cookie_domain directive rewrites the Domain attribute of Set-Cookie headers passed from a proxied server. — NGINX HTTP Core
Описание
The `proxy_cookie_domain` directive is utilized in NGINX when acting as a reverse proxy, specifically for modifying the Domain attribute of cookies set by upstream servers. This directive allows you to specify a new domain that the cookies should be available for when they are sent back to the client. It accepts one or two arguments: the first is the original domain from which the cookie is set, and the second optional argument is the domain to rewrite to. If only one argument is specified, it replaces the domain with the server's domain, which is useful when both upstream and NGINX are on the same domain to ensure that cookies can be accessed as expected.
Пример конфига
location / {
proxy_pass http://backend;
proxy_cookie_domain example.com my-website.com;
}Make sure that the new domain is set correctly; otherwise, cookies may not be sent back to the client properly.
If only the original domain is provided, NGINX will default to the server's domain, so ensure it aligns with your requirements.