簡體   English   中英

配置Nginx以接受來自特定子域上單個主機/ IP的連接

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM