Created
April 14, 2011 22:02
-
-
Save gjuric/920669 to your computer and use it in GitHub Desktop.
ugly nginx rewrite
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
server { | |
listen IP-ADDRESS:80; | |
root /root/path; | |
location ^~ /img { | |
rewrite ^/img/([a-z0-9])([a-z0-9])([a-z0-9])(.*)$ /repository/images/$1/$2/$3/$1$2$3$4 last; | |
} | |
location /repository/images { | |
if (!-e $request_filename) { | |
rewrite ^/repository/images/(.)/(.)/(.)/(.*)$ /api/image.php?filename=$4; | |
proxy_pass http://IP-ADDRESS:8080; | |
break; | |
} | |
} | |
location ~* \.(?:jpe?g|gif|png|ico|css|js|pdf|flv|mp4|swf|mp3|zip)$ { | |
expires max; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
location / { | |
proxy_pass http://IP-ADDRESS:8080; | |
} | |
} |
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
server { | |
listen IP-ADDRESS:80; | |
root /root/path; | |
location ^~ /img { | |
rewrite ^/img/([a-z0-9])([a-z0-9])([a-z0-9])(.*)$ /repository/images/$1/$2/$3/$1$2$3$4; | |
if (!-e $request_filename) { | |
rewrite ^/repository/images/(.)/(.)/(.)/(.*)$ /api/image.php?filename=$4; | |
proxy_pass http://IP-ADDRESS:8080; | |
break; | |
} | |
expires max; | |
} | |
location /repository { | |
expires max; | |
} | |
# Serve static files directly | |
location ~* .+\.(txt|gif|jpg|png|jpeg|ico|css|js|pdf|flv|mp4|swf|mp3|zip)$ | |
{ | |
expires max; | |
} | |
location / { | |
proxy_pass http://IP_ADDRESS:8080; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment