Reputation: 2111
I'm new to NGINX. Currently running a local reverse proxy using NGINX.
Just wondering how I can change the Referer in the request header from http://localhost:8080 to say a different server_name like me.example.com
Finding it difficult to find clear documentation on this subject. have tried setting this value using:
proxy_set_header Referer "me.example.com";
Doesn't seem to do anything.
Any help on this greatly appreciated.
server {
listen 8080;
server_name localhost;
# test APi
location /test/api {
# Edit this line only:
proxy_pass https://test.com/test/api;
proxy_set_header Host $http_host;
break;
}
location / {
proxy_pass http://localhost:4567;
proxy_set_header Host $http_host;
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_set_header Referer "me.example.com";
}
}
Upvotes: 5
Views: 27848
Reputation: 2283
The proxy_set_header
directive sends headers to the backend. If you want nginx to return headers to the client, then the add_header
directive is what you're looking for.
http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header
Upvotes: 3