- http://example.com: my site
- http://example.net: the proxied backend
I'm trying to setup an nginx server block as both a static content server and a reverse proxy. Nginx should first check for static files and then redirect to the proxied application if no file exists. It is configured as such:
location @backend { proxy_pass http://example.net; } location / { try_files $uri $uri/ @backend; } However, with such a configuration accessing http://example.com returns a 403 Forbidden: it seems that nginx tries to serve a static folder, does not find an index.html and fails without proxying example.net. I then have to explicitly add a route for /:
location = / { proxy_pass http://example.net; } That way http://example.com/ is properly proxied to http://example.net. But such a configuration feels odd: is there a better way to proxy / ?
