Created
December 20, 2018 06:39
-
-
Save koheyamada/9b10edd876a7c3dad19dc58b0b67a516 to your computer and use it in GitHub Desktop.
nginxでメンテナンスページを表示させる。改良版 ref: https://qiita.com/kooohei/items/095eb1304f9fa67ed1a1
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
error_page 500 @maintenance; | |
# Set Env | |
set $maintenance "on"; | |
# Allow Paths | |
if ($uri ~ "^/exclude/") { | |
set $maintenance "off"; | |
} | |
# Allow IPs | |
if ($remote_addr ~ "xxx.xxx.xxx.xxx") { | |
set $maintenance "off"; | |
} | |
if ($http_x_forwarded_for ~ "xxx.xxx.xxx.xxx") { | |
set $maintenance "off"; | |
} | |
# maintenance | |
if ($maintenance = "on") { | |
return 500; | |
} | |
location @maintenance { | |
rewrite ^(.*)$ /maintenance.html break; | |
} |
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
# include /etc/nginx/conf.d/maintenance; | |
rewrite ^/maintenance.html(.*)$ https://$host/ permanent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment