Reputation: 998
i have 3 heroku apps
the /etc/nginx/conf.d/default.conf
code
upstream frontend {
server $FRONTEND_URL;
}
upstream backend {
server $BACKEND_URL;
}
server {
listen $PORT;
location / {
proxy_pass http://frontend;
proxy_set_header Host $FRONTEND_URL;
}
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://backend;
proxy_set_header Host $BACKEND_URL;
}
}
issue
i am using cookie for authentication but the cookie being set by backend is not being 'forwarded'
now it works, changes i made:
secure: false
in my node app did it for me (will add tls certificate later maybe)now it looks like
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://backend;
proxy_set_header Host $BACKEND_URL;
proxy_set_header Cookie $http_cookie;
}
app.set("trust proxy", true);
Upvotes: 8
Views: 17485
Reputation: 700
You need add
proxy_set_header Cookie $http_cookie;
in location config. Variable $http_cookie is user request cookie.
Upvotes: 9