Last active
August 29, 2015 13:56
-
-
Save acrookston/8911485 to your computer and use it in GitHub Desktop.
basic nginx config for rails and puma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream rails { | |
server unix:///var/www/CHANGE/current/tmp/sockets/puma.sock; | |
} | |
server { | |
listen 80; | |
server_name CHANGE; | |
root /var/www/CHANGE/current/public; | |
client_max_body_size 8M; | |
location ~* ^/assets/ { | |
expires 1y; | |
add_header Cache-Control public; | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto http; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
if (!-f $request_filename) { | |
proxy_pass http://rails; | |
break; | |
} | |
} | |
} | |
server { | |
listen 443; | |
ssl on; | |
ssl_certificate /etc/nginx/ssl_cert.pem; | |
ssl_certificate_key /etc/nginx/ssl_server.key; | |
server_name CHANGE; | |
root /var/www/CHANGE/current/public; | |
client_max_body_size 8M; | |
location ~* ^/assets/ { | |
expires 1y; | |
add_header Cache-Control public; | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
if (!-f $request_filename) { | |
proxy_pass http://rails; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment