nginx 如何禁止指定ip访问【附代码】

今天爱分享给大家带来nginx 如何禁止ip访问【附代码】,希望能够帮助到大家。

编辑nginx.conf文件,编辑server前如下所示

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's do喂饭ent root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

server_name localhost;修改为server_name _;即可禁止IP访问

原文链接:https://blog.itblood.com/691.html,转载请注明出处。
0
NTR手机 V0.30 官方中文版 [PC+安卓] [更新] [670M] [SLG/中文/NTR]
NTR手机 V0.30 官方中文版 [PC+安卓] [更新] [670M] [SLG/中文/NTR]
刚刚 有人购买 去瞅瞅看

站点公告

显示验证码
没有账号?注册  忘记密码?