Created
June 3, 2019 03:24
-
-
Save alvin2ye/3a6cb21ed4ff92f79c051a2e6f1597ab to your computer and use it in GitHub Desktop.
nginx-app-3000.conf
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 app_web_services { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 80; | |
root /app/public; | |
gzip on; | |
gzip_types text/plain text/xml application/xml application/xml+rss | |
text/css text/javascript application/javascript application/json; | |
error_page 551 =503 @maintenance; | |
location @maintenance { | |
rewrite ^(.*)$ /system/maintenance.html break; | |
} | |
set $maintenance 0; | |
if (-f $document_root/system/maintenance.html) { | |
set $maintenance 1; | |
} | |
if ($request_uri = /favicon.ico) { | |
# Browsers will try to get favicon if it's not returned with 200ok status | |
set $maintenance 0; | |
} | |
if ($maintenance) { | |
# There can be several reasons for 503 error. We custom return 551 error | |
# to ensure maintenance.html is only shown when it's really maintenance | |
return 551; | |
} | |
rewrite ^/(.*)/$ /$1 permanent; # Truncate trailing slashes | |
try_files $uri @rails; | |
expires -1; | |
location = /favicon.ico { | |
try_files $uri =204; | |
access_log off; | |
log_not_found off; | |
} | |
location @rails { | |
proxy_pass http://app_web_services; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_intercept_errors on; | |
expires -1; | |
} | |
error_page 500 502 503 504 /500.html; | |
error_page 403 /403.html; | |
error_page 404 /404.html; | |
client_max_body_size 50M; | |
keepalive_timeout 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment