鍍金池/ 問(wèn)答/Java  Linux/ 如圖,nginx的server_name并沒(méi)有配置的域名為什么也能轉(zhuǎn)發(fā)?

如圖,nginx的server_name并沒(méi)有配置的域名為什么也能轉(zhuǎn)發(fā)?

server_name只是配置了e-house.cn www.e-house.cn
為什么輸入louqibang.com的時(shí)候,也一樣會(huì)轉(zhuǎn)發(fā)到ehouse這個(gè)項(xiàng)目?
圖片描述

回答
編輯回答
悶騷型

這個(gè)問(wèn)題在nginx文檔中可以找到原因

If a server is the only server for a listen port, then nginx will not test server names at all (and will not build the hash tables for the listen port). However, there is one exception. If a server name is a regular expression with captures, then nginx has to execute the expression to get the captures.

也就是說(shuō),如果某個(gè)端口下只有一個(gè)server_name的時(shí)候,所有訪問(wèn)該端口的請(qǐng)求,不管server_name是什么,都會(huì)由該server塊處理。

請(qǐng)看 Server Names

2017年2月14日 16:15