安装了nginx并在端口8080上安装了Apache。问题是:我正在为生产域(比如mysite.com )构build网站,并为该域configuration了一切。 我更改我的Windows主机文件redirectmysite.com到服务器的IP,它运行良好…在我安装nginx之前。 Nginx自己parsing域名(显然)不能parsing域名mysite.com
日志说:
2012/02/07 07:35:29 [error] 11758#0: *1 mysite.com could not be resolved (110: Operation timed out), client: 89.112.11.xx, server: myssite.com, request: "GET / HTTP/1.1", host: "mysite.com"
那么,我尝试更改我的服务器上的主机文件。 我在/ etc / hosts中做了这个事情:
127.0.0.1 mysite.com
好吧,我们试试吧! 如果这个生效,至lesswget应该find正确的,对吧? 据我在第8080端口的Apache,我可以wget主页面:
wget mysite.com
它下载正确的页面。 这意味着/ etc / hosts很好。
但是ngnix仍然不能解决它! 即使我重新启动服务器。 为什么? 它有自己的parsing器还是什么? 如何使其工作?
nginx不使用hosts文件进行域parsing。 如果您为listen , proxy_pass或fastcgi_pass使用域名,则可以使用IP地址或localhost :
listen localhost:80; server_name mysite.com; ... location / { proxy_pass http://localhost:8080; }
你可以使用127.0.0.1上的dnsmasq来parsing/ etc / hosts,并将parsing器127.0.0.1放置到nginx config