Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
nginx configuration
upstream app_name {
server unix:///tmp/app_name.sock;
server {
listen 80;
return 301 $scheme://$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; # 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 "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment