Nginx: location regex for multiple paths
Solution 1:
According to nginx documentation:
Then regular expressions are checked, in the order of their appearance in the configuration file. The search of regular expressions terminates on the first match, and the corresponding configuration is used.
In your configuration, the following location is defined before the one with the proxy_pass and it matches the request of js and css files under static:
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
Unfortunately the "log_not_found off" clause disables the logging for any file-not-found error related to this location, that's why your error_log is empty!
You can try to comment out this location or move it after the location with the proxy_pass (if you need it for other files not in static / media).
Solution 2:
location ~ ^/(static|media)/ {
proxy_pass http://backend.example.com;
) <-----------
Should be...
location ~ ^/(static|media)/ {
proxy_pass http://backend.example.com;
} <-----------
The closing needs to be a brace {}, not a parenthesis bracket ().
Can't believe how long it took to see that. Guido was right from the comments.