nginx配置文件跟hosts文件的先后关系

WBOY
Release: 2016-06-13 12:19:15
Original
2012 people have browsed it

nginx配置文件和hosts文件的先后关系
我想问一下windows中hosts中的映射项和nginx中配置的server的host的关系是什么?当使用浏览器进行访问时,域名是否先在hosts文件中进行查找,然后通过ip地址去访问资源,那nginx是不是不会对该请求进行匹配(因为是ip地址)?
------解决思路----------------------

引用:
我想问一下windows中hosts中的映射项和nginx中配置的server的host的关系是什么?当使用浏览器进行访问时,域名是否先在hosts文件中进行查找,然后通过ip地址去访问资源,那nginx是不是不会对该请求进行匹配(因为是ip地址)?



是通过ip访问资源的,但是nginx会找到请求头里面的hostname,来匹配需要那个配置文件来处理该响应
<br />GET /rabbit/tracking-ad/main.js.map HTTP/1.1<br />Host: csdnimg.cn //注意这个,nginx会根据这个匹配servername<br />Connection: keep-alive<br />Cache-Control: max-age=0<br />User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36<br />Accept: */*<br />Referer: http://bbs.csdn.net/forums/PHP<br />Accept-Encoding: gzip, deflate, sdch<br />Accept-Language: zh-CN,zh;q=0.8<br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template