admin管理员组文章数量:1312849
I have three different applications running behind a NGINX reverse proxy.
They all have a login GUI, which uses the same authentication API. Authentication is based on cookies.
My problem is now, that the pathes of the cookies are set differently depending on which GUI is used to login.
The authentication API, actually sets the cookie-path to /, but I assume it is the NGINX proxy, which is overwriting that depending on the location.
Is there a way to set the path of the cookies to /, regardless which GUI is used?
This is how my NGINX configuration looks like:
http {
server {
listen 80;
server_name localhost;
location = / {
rewrite / /admin;
}
location /admin/ {
proxy_pass http://localhost:9001/;
}
location /app/ {
proxy_pass http://localhost:3100/;
}
location / {
proxy_pass http://localhost:3000/;
}
}
}
Edit 1: I have tried to add
proxy_cookie_path ~*^/.* /;
as described here, but it didn't help. The path of the cookie is still /admin or /app
I have three different applications running behind a NGINX reverse proxy.
They all have a login GUI, which uses the same authentication API. Authentication is based on cookies.
My problem is now, that the pathes of the cookies are set differently depending on which GUI is used to login.
The authentication API, actually sets the cookie-path to /, but I assume it is the NGINX proxy, which is overwriting that depending on the location.
Is there a way to set the path of the cookies to /, regardless which GUI is used?
This is how my NGINX configuration looks like:
http {
server {
listen 80;
server_name localhost;
location = / {
rewrite / /admin;
}
location /admin/ {
proxy_pass http://localhost:9001/;
}
location /app/ {
proxy_pass http://localhost:3100/;
}
location / {
proxy_pass http://localhost:3000/;
}
}
}
Edit 1: I have tried to add
proxy_cookie_path ~*^/.* /;
as described here, but it didn't help. The path of the cookie is still /admin or /app
Share Improve this question edited Mar 14, 2019 at 16:23 Stefan Meier asked Mar 14, 2019 at 13:05 Stefan MeierStefan Meier 1531 gold badge1 silver badge9 bronze badges1 Answer
Reset to default 5The directive proxy_cookie_path is for sure the solutions for the described problem.
(I just found out that my cookie wasn't set from the serverside API but on the client side. So the problem wasn't the NGINX config.)
So for the record:
proxy_cookie_path ~*^/.* /;
should do the trick if the cookie is set from serverside. For more information about the directive, see here.
本文标签: javascriptCookie path with NGINX reverse proxyStack Overflow
版权声明:本文标题:javascript - Cookie path with NGINX reverse proxy - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741877956a2402575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论