nginx配置白名單


1、在server里邊配置,對該域名的所有服務進行添加白名單,統籌配置

 server {
        listen 443 ssl;
        server_name         www.baidu.com;
        #設置長連接
        keepalive_timeout   70;
        #白名單ip
        include /usr/local/nginx/Whitelist/Whitelist.conf;
        ……………………其他配置
 }       
        
[root@localhost nginx]# cat /usr/local/nginx/Whitelist/Whitelist.conf 
#注釋ip
allow 36.113.98.246;

deny all;

 

2、在location中配置,只對該域名下的某個服務進行添加白名單,個別配置

 server {
        listen 443 ssl;
        server_name         www.baidu.com;
        #設置長連接
        keepalive_timeout   70;
        ……………………其他配置
        #只對該域名下的portal服務限制白名單訪問
        location /portal {
            allow 36.113.98.246;
            deny all;
             ……………………其他配置
           }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM