7

I have set up a very basic proxy rule in nginx. However the resources where the request are proxyed do a referer check. It must be the same domain the service is running at. I therefore need to change the referer. I tried a proxy_set_header but that doesn´t seem to work.

Am I missing something or is there any other way to do this?

location /api/v1/ {
    proxy_pass http://192.168.10.10:8080;
    proxy_set_header Referer "http://192.168.10.10";
}
mawie
  • 71
  • 1
  • 1
  • 3

2 Answers2

4

You say that the proxied server asks for a domain name as a referer. Try that domain name instead of IP address.

proxy_set_header Referer "http://proxied-domain-here.com";
Nick
  • 41
  • 2
  • Thanks for this. I was having a similar issue, which was solved by quoting the new referer string and adding "http://" to the beginning. – Bri Bri May 09 '18 at 19:57
  • This can be a bad idea for CSRF. However, nginx doesn't seem to provide a way to edit the referer header. – Pawel Veselov Jun 05 '18 at 17:54
2

Few years later, but this could be helpful to somewhere, you miss the port at the referer header (:8080):

    proxy_set_header Referer "http://192.168.10.10:8080";

I hope can be helpful.