Last active
August 29, 2015 14:14
-
-
Save nakamura-akifumi/ab809e4837ad18613557 to your computer and use it in GitHub Desktop.
nginx default.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_server { | |
server unix:/tmp/unicorn_${appname}.sock fail_timeout=0; | |
# for TCP setups, point these to your backend servers | |
#server localhost:3000 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name ${hostname}; | |
server_tokens off; | |
access_log /var/log/nginx/access.log combined; | |
client_max_body_size 1G; | |
keepalive_timeout 5; | |
#try_files $uri/index.html $uri.html $uri @app; | |
# ================================================= | |
# maintenance mode: touch /var/tmp/do_const | |
# regular mode : rm /var/tmp/do_const | |
if (-e /var/tmp/do_const) { | |
set $maintenance true; | |
} | |
if ($remote_addr = 127.0.0.1) { | |
set $maintenance false; | |
} | |
#if ($remote_addr = 'xxx.xx.xxx.xxx') { | |
# set $maintenance false; | |
#} | |
error_page 503 @maintenance; | |
location @maintenance { | |
rewrite ^(.*)$ /maintenance.html; | |
root /opt/${appname}/public; | |
break; | |
} | |
if ($maintenance = true) { | |
#rewrite ^ /maintenance.html last; | |
return 503; | |
} | |
# ================================================= | |
location / { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
# pass the Host: header from the client right along so redirects | |
# can be set properly within the Rack application | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
# per-response basis. | |
# proxy_buffering off; | |
#auth_basic "Local Security"; | |
#auth_basic_user_file "/opt/${appname}/.htpasswd"; | |
proxy_pass http://app_server; | |
} | |
add_header X-Frame-Options SAMEORIGIN; | |
add_header X-Content-Type-Options nosniff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment