I have nodejs and nginx running i am sending an additional header in the API 'api_key' and its not received in req.headers and req.get('api_key') in nodejs i have bellow configuration file for nginx
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name mysite.com;
return 301 https://$host$request_uri;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:9102/;
proxy_set_header Host $http_host;
proxy_set_header api_key $http_api_key;
#proxy_set_header api_key 'Some Value'; works
proxy_redirect off;
}
}
If set the value of proxy_set_header api_key 'some value' it works and headers are printed on console but the api_key is subjected to change that's why i am using $http_api_key so that whatever comes in api_key custom header is received as it is sent from rest client. I have tried couple of solutions like proxy_set_header api_key $upstream_http_api_key; but no help. I want to receive any custom header sent from rest client in nodejs.
proxy_pass_header api_key;and not set it yourself. See if that helps