6

I have a single file that I want to appear to host but that I don't. So I write this in my nginx server block:

location /d-p27.js {
  proxy_pass https://data.example.com/p/piwik.js;
}

After reloading nginx's config, when I test this with curl -I https://another.example.com/d-p27.js, I get a 404. The nginx logs don't say any more than that.

So I try this:

location /d-p27.js {
  rewrite ^/d-p27.js$ /p/piwik.js break;
  proxy_pass https://data.example.com/;
}

This also 404's. Any suggestions?

The solution

Thanks to @RichardSmith, the solution is simply to use an exact match to avoid confusion with other regex's:

location = /d-p27.js {
  proxy_pass https://data.example.com/p/piwik.js;
}
jma
  • 415
  • 5
  • 15

0 Answers0