我正在用以下configuration使用nginx创build虚拟主机:
server { listen 7001; server_name example.com; location / { root html; index index.html index.htm; } }
当我尝试访问example.com或exemple.com:7001 ,它不工作,但它正在工作,当我通过localhost:7001访问localhost:7001 ,在我的configuration错误?
我在Windows平台上
当我尝试通过example.com或example.com:7001访问时,它将访问在线example.com网站,或者在访问example.com:7001时发现网站未find通知:
您需要确保DNS名称example.comparsing为运行nginx的IP地址。 在这种情况下,这是你的本地IP地址,所以127.0.0.1可以工作。
基本上你需要在你的HOSTS文件中input这样的内容:
127.0.0.1 example.com
在这里寻找关于如何编辑你的HOSTS文件的说明。
所以,当你ping它或运行nslookup example.com时 ,它parsing为一个IP地址,特别是127.0.0.1