I have a setup comprised by 2 nginx instances connected one after the other. The first one is on one server (A)
and the second one is on a second server (B)
:
user <-> nginx (A) <-> nginx (B) <-> api frontend (B)
<-> api backend (B)
Server (A)
is protected by SSL, and then forwards requests to server (B)
using proxy_pass
. This is from A's config:
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://B;
}
And a simlar things happen on (B)
, to pass all the requests to the actual application (there are other location directives, but this one is the relevant one):
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://api_frontend;
}
I'm having problems with session cookies. The application (api frontend) correctly sets the cookies and I can see them with the browser inspector. However, when the application reads cookies, it only receives some cookies but not the session one. I think there is some kind of problem with the double nginx configuration.