NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Livid
291.9D
558.2D
V2EX  ›  NGINX

NGINX 在配置默认主机的时候, listen 后面加 default_server 和 server_name 配置为 _ 有什么不同吗?

  •  
  •   Livid ·
    PRO
    · Apr 23, 2018 · 8383 views
    This topic created in 2981 days ago, the information mentioned may be changed or developed.
    7 replies    2018-04-23 09:08:12 +08:00
    julyclyde
        1
    julyclyde  
       Apr 23, 2018
    不是有什么不同,而是根本就没关系
    isCyan
        2
    isCyan  
       Apr 23, 2018 via Android
    理解上应该是 listen default 是针对端口的吧,比如 http 的未知域名和 https 的未知域名可以被导向不同的两个 server
    回去我试一下
    salmon5
        4
    salmon5  
       Apr 23, 2018 via Android
    这个问题我想过,default_name 可以请求任意 host 头,_对 host 头做了一定的安全性约束。
    最优雅的还是默认主机返回 403 或 501 等。
    ragnaroks
        5
    ragnaroks  
       Apr 23, 2018
    In catch-all server examples the strange name “_” can be seen:

    server {
    listen 80 default_server;
    server_name _;
    return 444;
    }
    There is nothing special about this name, it is just one of a myriad of invalid domain names which never intersect with any real name. Other invalid names like “--” and “!@#” may equally be used.
    Livid
        7
    Livid  
    MOD
    OP
    PRO
       Apr 23, 2018
    @salmon5 嗯,是的,其实问这个问题的原始需求,就是我在想,一个最佳的默认 catch all server 段应该是怎样的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2641 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 05:16 · PVG 13:16 · LAX 22:16 · JFK 01:16
    ♥ Do have faith in what you're doing.