Last active
April 15, 2022 21:44
My nginx configuration file for AL2 setup
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:///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