Reputation: 7461
I'm trying to proxy a sub path in my web app to an asset server (to avoid cross domain issues).
I've added this configuration to the server context in nginx.conf.
location /assets2/ {
proxy_pass http://itype-assets/videos/transparent/classroom.png;
}
location /assets/ {
proxy_pass http://itype-assets/;
}
After adding this config I'm finding that:
http://localhost:8080/assets2/ - serves up the expected image
http://localhost:8080/assets/videos/transparent/classroom.png - returns 404
What am I missing here?
Edit :
On further investigation I've discovered that removing a subsequent rule resolves the issue:
location ~ ^.+\..+$ {
try_files $uri =404;
}
However, I need that rule to serve my static files. Changing the order the rules are declared in doesn't alter the behaviour.
So my question becomes, how can I use my proxy_pass rule alongside my try_files rule?
Upvotes: 0
Views: 192
Reputation: 7461
It turns out nginx will always resolve regex location matches over prefix location matches.
This behaviour can be overridden by modifying my location declaration to:
location ^~ /assets/ {
proxy_pass http://itype-assets/;
}
Upvotes: 0