I'm just getting my feet wet with nginx. In the past I've used an .htaccess file in /wp-content/uploads so if my dev or staging server doesn't have the file it redirects to the production server:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://production.server.com/m/wp-content/uploads/$1 [L,P]
</IfModule>
I'm not having luck with doing this in nginx. It may be in part because this particular time my site is in a subdirectory (/m/).
# Tells nginx which directory the files for this domain are located
root /srv/www/example/htdocs;
index index.php;
# Subdirectory location settings
location /m {
index index.php;
try_files $uri $uri/ /m/index.php?$args;
location /m/wp-content/uploads {
try_files $uri $uri/ @prod_svr;
}
}
location @prod_svr {
proxy_pass http://production.server.com/m/wp-content/uploads$uri;
}
Any ideas would be greatly apprciated.
$uri
is/m/wp-content/uploads/xxx
so you should not be prefixing the path again.