zoukankan      html  css  js  c++  java
  • Nginx访问控制

    Nginx访问控制

    一、黑(白)名单

    [root@web-nginx conf.d]# vim access-control.conf
    server {
            listen 80;
            server_name www.access-control.com;
            access_log /var/log/nginx/access-control-access.log main;
            error_log /var/log/nginx/access-control-error.log;
    
            location /{
                    root /var/www/access;
                    index index.php index.htm index.html;
            }
    
    #设置白名单访问/status页面
            location /status{
                allow 192.168.133.0/24;
                deny all;
                stub_status on;
                access_log off;
            }
    }
    
    

    二、账号访问

    [root@web-nginx conf.d]# yum -y install httpd-tools
    [root@web-nginx conf.d]# htpasswd -c /var/www/auth_conf test
    password:
    
    [root@web-nginx conf.d]# vim access-control.conf
    server {
            listen 80;
            server_name www.access-control.com;
            access_log /var/log/nginx/access-control-access.log main;
            error_log /var/log/nginx/access-control-error.log;
    
            location /{
                    root /var/www/access;
                    index index.php index.htm index.html;
            }
    #指定页面设置账号访问
    		location = /xxx.html{
                auth_basic "input user,password!";
                auth_basic_user_file /var/www/auth_conf;
                index index.html index.htm;
    	}
        
    
    }
    
    配置若有遗漏或错误,请评论留言。
  • 相关阅读:
    Netsharp下微信菜单以及OAuth
    权限管理
    java面向对象基础(转)
    闲来无事做了一个批处理的win10账号管理
    bat获取系统时间修改系统密码
    bat常用命令
    bat修改密码
    vbs的一些入门基础。。。
    WCF 之 DataContract
    WCF 之 OperationContract
  • 原文地址:https://www.cnblogs.com/BrokenEaves/p/15165829.html
Copyright © 2011-2022 走看看