-
-
Save scarfacedeb/ebbd2392a9e3858adfb4 to your computer and use it in GitHub Desktop.
Using Nginx as a caching proxy for Refile with Ruby on Rails
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
http { | |
... | |
proxy_cache_path /data/perch.squaremill.com/shared/image_cache levels=1:2 keys_zone=images:10m; | |
... | |
} |
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 80; | |
server_name www.somedomain.com; | |
location /attachments { | |
proxy_pass http://127.0.0.1:81; | |
proxy_ignore_headers Set-Cookie; | |
proxy_hide_header Set-Cookie; | |
proxy_cache images; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host "www.somedomain.com:80"; | |
proxy_redirect off; | |
proxy_pass http://127.0.0.1:81/; | |
} | |
} | |
server { | |
listen 81; | |
server_name somedomain.com; | |
root /data/somedomain.com/current/public; | |
passenger_enabled on; | |
rack_env production; | |
passenger_min_instances 2; | |
location ~ ^/assets/ { | |
expires 1y; | |
add_header Cache-Control public; | |
# to serve pre-gzipped version, requires nginx compiled with this | |
gzip_static on; | |
# Some browsers still send conditional-GET requests if there's a | |
# Last-Modified header or an ETag header even if they haven't | |
# reached the expiry date sent in the Expires header. | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment