[英]Configure nginx to accept connection from a single host/ip on specific subdomain
我想知道如何配置nginx以允许访问子域的单个IP。
这意味着,除dev-stg.domain.com
之外,所有*.domain.com
都可以公开访问。
您可能已经猜到了,我正在尝试为预生产检查保留一个子域。
我建议使用地理模块:
geo $unknown_ip {
default 1;
192.0.2.1 0; # or use CIDR notation
}
server {
listen 80;
server_name example.com;
location / {
if ($unknown_ip) {
return 403;
}
try_files $uri $uri/ =404;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.