nginx安全配置 黑白名单访问

  sre

白名单:

location /admin/ {
    allow   192.168.1.0/24;
    deny    all;
}

黑名单:

location /ops-coffee/ {
    deny   192.168.1.0/24;
    allow    all;
}

有代理情况下:

set allow false;
if (http_x_forwarded_for = "211.144.204.2") { set allow true; }
if (http_x_forwarded_for ~ "108.2.66.[89]") { set allow true; }
if (allow = false) { return 404; }

LEAVE A COMMENT

Captcha Code