• nginx 配置禁用ip地址访问


    IP访问限制使用 ngx_http_access_module 模块,可以在 httpserverlocationlimit_except 中配置,语法如下:

    采用黑名单规则,禁止所有,添加访问IP。
        allow IP;
        deny  all;

     

    想禁止所有虚拟主机的访问,在nginx.conf配置:

    include vhost/*.conf;

    配置IP文件,允许访问的IP添加文件中。

    [root@yunwei-test vhost]# cat blockips.conf.bak 
    # allow all ips
    allow    10.0.2.174;
    # block all ips
    deny    all;

    只想禁止某一个虚拟主机禁止访问:

    # 现在有两个虚拟主机,bbs.qipai.com 和 www.qipai.com 现在想对访问 www.qipai.com 做访问限制。 

    [root@yunwei-test vhost]# ls bbs.qipai.conf blockips.conf.bak www.qipai.conf
    [root@yunwei
    -test vhost]# cat www.qipai.conf server { listen 80; server_name www.qipai.com; allow 10.0.2.174; # 直接在server区块中配置 deny all; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

    这样就对访问 www.qipai.conf 的做了访问限制,访问 bbs.qipai.conf 不受影响。

    官方文档:http://nginx.org/en/docs/http/ngx_http_access_module.html

  • 相关阅读:
    Fetch the result from result set
    Variable shadowing
    What is Servlet Container
    What is a servletcontext
    Inner Class
    Java中HashMap和TreeMap的区别深入理解
    枚举类
    (转载) 安卓开发学习笔记
    【C和C++】停车场系统
    【算法】常用的排序方法
  • 原文地址:https://www.cnblogs.com/root0/p/10179301.html
Copyright © 2020-2023  润新知