欢迎来到ArchitecTang的博客

Nginx 配置临时维护页

网站需要对外网关闭,但是内部需要能够正常访问,在nginx上做如下配置:

    location / {
        root   html;
        index  index.html index.htm;
    if ( $remote_addr !~* "192.168.1.41") {    #只允许192.168.1.41这个IP访问,其他IP均返回403状态码
        return 403;
     }
    }
    error_page 404 403 /maintenance/index.html;    #匹配403 404 状态码,并将请求转发至/maintenance/index.html页面
    location = /maintenance/index.html {
           root html;
    }
posted @ 2020-01-07 14:41  ArchitecTang  阅读(274)  评论(0编辑  收藏  举报