Having nginx installed and Apache on port 8080. The trouble is: I'm building site for production domain (let's say mysite.com) and have everything configured for that domain. I change my Windows hosts file to redirect mysite.com to server's IP and it worked well... before I installed nginx. Nginx resolves domains itself and (obviously) can't resolve the domain mysite.com
Log says:
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"
Well, then I try to change hosts file on my server. I do this thing in the /etc/hosts:
127.0.0.1 mysite.com
Okay, let's try! If this took effect, at least wget should find it correct, right? As far as I have Apache on the 8080th port, i can wget the main page:
wget mysite.com
It downloads the correct page. This means that /etc/hosts does well.
But ngnix still does not resolve it! Even after I restarted the server. Why? Does it have its own resolver or what? How to make it work?
you can use dnsmasq on 127.0.0.1 for resolving from /etc/hosts and place resolver 127.0.0.1 to nginx config
nginx doesn't use
hosts
file for domain resolving. If you use domain names forlisten
,proxy_pass
orfastcgi_pass
, you can use IP address orlocalhost
instead: