Nginx IP 白名单设置

1:ip.config

192.168.3.15 1;
192.168.3.10 1;
192.168.0.8 1;

 

2:nginx.conf

#geoIP的白名单
geo $remote_addr $ip_whitelist {
default 0;
include ip.conf;
}

location /console {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#白名单配置
if ( $ip_whitelist = 1 ) {
proxy_pass http://192.168.3.15:9401;
break;
}

return 403;
}

 

转载于:https://www.cnblogs.com/yshyee/p/7389379.html

你可能感兴趣的:(Nginx IP 白名单设置)