Created
February 27, 2014 23:04
-
-
Save casivaagustin-zz/9261586 to your computer and use it in GitHub Desktop.
nginx location rule to redirect non existing images to another server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Rewrites the request, extracting a fragment of the file name and using a remote server. | |
location @fetchFromRemote { | |
rewrite ^/path/to/images/(.*)$ http://remoteserver.com/other/path/to/images/$1 redirect; | |
} | |
#Will try to see if we have the file in this server, is not will use fetchFromRemote | |
location ~ ^/path/to/images/.*(png|jpg|jpeg|gif|ico|swf)$ { | |
try_files $uri @fetchFromRemote; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment