nginx设置禁止 IP 访问网站

直接上设置:

server {
        listen 80 default;
        server_name _;
        return 403;
    }

 

 

删除以下部分:

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

 

 

然后访问直接 403

 

posted @ 2019-05-27 22:42  小寒1206  阅读(546)  评论(0编辑  收藏  举报