Skip to content

Instantly share code, notes, and snippets.

@VladoMS
Forked from conorh/nginx.conf
Created July 1, 2016 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladoMS/6223c5945964dfb64bfa05ef8fe5a4a9 to your computer and use it in GitHub Desktop.
Save VladoMS/6223c5945964dfb64bfa05ef8fe5a4a9 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