nginx模块学习二 http_access_module IP访问控制

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

  • 语法
  1. 允许ip
    Syntax:allow address | CIDR |unix | all;
    Default:--
    Context:http,server,locaton,limit_except

     

  2. 阻止ip
    Syntax: deny address | CIDR | unix: | all;
    Default: --
    Context: http,server,locaton,limit_except

     

  •  例:/etc/nginx/conf.d/default.conf 
    server {listen       80;server_name  localhost;#charset koi8-r;#access_log  /var/log/nginx/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;}location ~  ^/admin.html {root   /opt/app/code;deny 192.168.0.116;  					##阻止192.168.0.116访问allow all;								##允许所有index  index.html index.htm;}location ~  ^/1.html {root   /opt/app/code;deny 192.168.0.0/116;  					##阻止ip段访问allow all;								##允许所有index  index.html index.htm;}location ~  ^/test.html {root   /opt/app/code;deny all;  									##阻止allow 192.168.0.116;						##允许index  index.html index.htm;}#error_page  404              /404.html;... ...

     

 

转载于:https://my.oschina.net/langgege/blog/1928677


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部