Skip to content

Instantly share code, notes, and snippets.

@damuz91
Last active April 15, 2022 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damuz91/e9e747450cbe219451c57267a8146ee1 to your computer and use it in GitHub Desktop.
Save damuz91/e9e747450cbe219451c57267a8146ee1 to your computer and use it in GitHub Desktop.
My nginx configuration file for AL2 setup
upstream rails {
server unix:///home/ec2-user/production/railsapp/current/puma.sock fail_timeout=0;
}
server {
server_name _;
root /home/ec2-user/production/railsapp/current/public;
location / {
proxy_pass http://rails;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 360s;
proxy_send_timeout 360s;
fastcgi_send_timeout 360s;
fastcgi_read_timeout 360s;
}
location ~ ^/(assets|packs)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
try_files $uri =404;
error_page 404 /404.html;
}
location ~ ^(?!/rails/).+\.(jpg|jpeg|gif|png|ico)$ {
gzip_static on;
expires max;
add_header Cache-Control public;
try_files $uri =404;
error_page 404 /404.html;
}
location ~ ^/(500|404|422).html {
root /home/ec2-user/production/railsapp/current/public;
}
error_page 500 502 503 504 /500.html;
error_page 404 /404.html;
error_page 422 /422.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment