Skip to content

Instantly share code, notes, and snippets.

@scarfacedeb
Forked from conorh/nginx.conf
Last active August 29, 2015 14:28
Show Gist options
  • Save scarfacedeb/ebbd2392a9e3858adfb4 to your computer and use it in GitHub Desktop.
Save scarfacedeb/ebbd2392a9e3858adfb4 to your computer and use it in GitHub Desktop.
Using Nginx as a caching proxy for Refile with Ruby on Rails
http {
...
proxy_cache_path /data/perch.squaremill.com/shared/image_cache levels=1:2 keys_zone=images:10m;
...
}
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