如图,nginx的server_name并没有配置的域名为什么也能转发?

server_name只是配置了e-house.cn www.e-house.cn
为什么输入louqibang.com的时候,也一样会转发到ehouse这个项目?
图片描述

阅读 3.6k
1 个回答

这个问题在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.

也就是说,如果某个端口下只有一个server_name的时候,所有访问该端口的请求,不管server_name是什么,都会由该server块处理。

请看 Server Names

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题