其实这是为了在挂停机维护的时候还开发可访问页面时,做的尝试所产生的,然而没找到方法,顺便就把这整理一下了,方法很多,大同小异,算是对nginx一些使用方法的整理记录
环境:nginx
修改location目标位置为停机维护页面位置
正常业务路径修改为停机维护页面位置
location /ok { #root /home/wwwroot/ok; root /home/wwwroot/tingji; index index.html; } # location ^~ /stop { # alias /home/wwwroot/stop/; # }
伪静态跳转
使用伪静态针对访问链接跳转到停机维护页面
if ( !-e $request_filename ) { rewrite ^/ok last; }
设置 deny 属性
在location 中加入 deny 和 allow 项,通过控制 ip 返回 403 状态码跳转到自定义的 403 页面
location /ok { allow 1.1.1.1; deny all; root /home/wwwroot/ok; index index.html; } error_page 403 /tingji.html; location = /tingji.html { root /home/lianyi/wwwroot/tingji; index tingji.html; }
© 著作权归作者所有
下一篇: SqlPlus 退格键 方向键 历史记录
文章评论(0)