Skip to content

Instantly share code, notes, and snippets.

@luugiathuy
Last active April 6, 2018 18:58
Show Gist options
  • Save luugiathuy/9054e96f2eb6d9773dbc to your computer and use it in GitHub Desktop.
Save luugiathuy/9054e96f2eb6d9773dbc to your computer and use it in GitHub Desktop.
nginx configuration
upstream app_name {
server unix:///tmp/app_name.sock;
}
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/app_name.crt;
ssl_certificate_key /etc/nginx/ssl/app_name.key;
server_name example.com; # change to match your URL
root /rails/app/folder/public; # I assume your app is located at that location
location / {
proxy_pass http://app_name; # match the name of upstream directive which is defined above
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;
proxy_set_header X-Forwarded-Ssl on;
}
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