Skip to content

Instantly share code, notes, and snippets.

@luugiathuy
Last active August 29, 2015 14:08
Show Gist options
  • Save luugiathuy/723280a597c4cbf30884 to your computer and use it in GitHub Desktop.
Save luugiathuy/723280a597c4cbf30884 to your computer and use it in GitHub Desktop.
upstream app_name {
server unix:///tmp/app_name.sock;
}
server {
listen 80;
server_name example.com; # change to match your URL
root /rails/app/folder/public; # change to match your rails app public folder
location / {
proxy_pass http://app_name; # match the name of upstream directive which is defined in line 1
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
expires 1y;
add_header Cache-Control public;
# 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