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

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

  •  
  •   Livid ·
    PRO
    · Apr 23, 2018 · 8711 views
    This topic created in 3135 days ago, the information mentioned may be changed or developed.
    7 replies  •  2018-04-23 09:08:12 +08:00
    julyclyde
    julyclyde
    Apr 23, 2018
    1
    不是有什么不同,而是根本就没关系
    isCyan
    isCyan
    Apr 23, 2018 via Android
    2
    理解上应该是 listen default 是针对端口的吧,比如 http 的未知域名和 https 的未知域名可以被导向不同的两个 server
    回去我试一下
    salmon5
    salmon5
    Apr 23, 2018 via Android
    4
    这个问题我想过,default_name 可以请求任意 host 头,_对 host 头做了一定的安全性约束。
    最优雅的还是默认主机返回 403 或 501 等。
    ragnaroks
    ragnaroks
    Apr 23, 2018
    5
    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
    Livid
    MOD
    OP
    PRO
    Apr 23, 2018
    7
    @salmon5 嗯,是的,其实问这个问题的原始需求,就是我在想,一个最佳的默认 catch all server 段应该是怎样的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1221 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 17:11 · PVG 01:11 · LAX 09:11 · JFK 12:11
    ♥ Do have faith in what you're doing.