Skip to content

Instantly share code, notes, and snippets.

@eru
Created February 5, 2016 01:51
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 eru/e58e11a6b2b851800d04 to your computer and use it in GitHub Desktop.
Save eru/e58e11a6b2b851800d04 to your computer and use it in GitHub Desktop.
##
## メンテナンスモード用コンフィグ
##
## How to use:
## maintenance mode on
## $ rename .conf .conf.maintenance *.conf && rename .conf.tmp .conf *.conf.tmp && service nginx restart
## maintenance mode off
## $ rename .conf .conf.tmp *.conf && rename .conf.maintenance .conf *.conf.maintenance && service nginx restart
##
## Tips:
## listen defaultの項目が、デフォルト設定をして使われることを利用して、他のconfigファイルを読み込まれない状態にした上で、
## このconfigファイルを有効にすることで、503のメンテナンス表示を行う。
## また、デフォルト表示のため、server_nameに指定するドメイン名はなんでもよい。
server {
listen 80 default;
server_name example.com;
root /etc/nginx/conf.d/;
location / {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
}
server {
listen 443 ssl default;
server_name example.com;
root /etc/nginx/conf.d/;
ssl on;
ssl_certificate /etc/pki/tls/certs/server.crt;
ssl_certificate_key /etc/pki/tls/certs/server.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment