在 Windows 10、Nginx 1.10.1 下,重新加载 Nginx,报错: nginx: [emerg] host not found in upstream “default.creditshop.shenzhen.localhost” in C:/nginx-1.10.1/conf/vhosts/credits hop_shenzhen.conf:26 的解决

1、在 Windows 10、Nginx 1.10.1 下,执行命令:nginx -s reload,重新加载 Nginx 配置,报错:
nginx: [emerg] host not found in upstream “default.creditshop.shenzhen.localhost” in C:/nginx-1.10.1/conf/vhosts/credits
hop_shenzhen.conf:26,如图1

图1

2、查看 Nginx 配置文件,发现在 proxy_pass 处报错,如图2

图2

3、编辑 hosts 文件,配置 default.creditshop.shenzhen.localhost 的解析,如图3

图3

4、执行命令:nginx -s reload,重新加载 Nginx 配置,正常,如图4

图4

5、由此发现,.localhost 仅在 Chrome 等一些浏览器下会自动转换为127.0.0.1,参考网址:http://www.shuijingwanwq.com/2017/12/12/2131/ ,在 Nginx 中不会转换

永夜