Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
basic nginx config for rails and puma
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
You can’t perform that action at this time.