I'm creating virtual host using nginx with following configuration:

server {
    listen       7001;
    server_name  example.com;

    location / {
        root   html;
        index  index.html index.htm;

When I trying access by example.com or exemple.com:7001, it is not working, but it is working when I access by localhost:7001, where is wrong in my configuration?

Edit 1

I'm in Windows platform

Edit 2

When I trying access by example.com or example.com:7001, it will access online example.com web site, or web site not found notification when access by example.com:7001

  • Do you have a firewall that blocks outside connections? – Dan Feb 24 '15 at 12:40
  • not have a firewall blocked, and I'm testing this in localhost, need I insert example.com in my hosts file? – Lai32290 Feb 24 '15 at 12:44
  • 1
    Is exemplo.com (or example.com? which one do we use?) resolving to an ip that is configured on your machine? Take it step by step, check all the basic stuff. – Dan Feb 24 '15 at 12:46
  • Is "exemple.com", sorry my bad, I will check this step by step – Lai32290 Feb 24 '15 at 12:48
  • Define/demonstrate "is not working" – AD7six Feb 24 '15 at 12:49

You need to be sure that the DNS name example.com resolves to the IP address where nginx is running. In this case, it's your local IP address, so would work.

Basically you need an entry in your HOSTS file like this: example.com

Look here for instructions on how to edit your HOSTS file.

So that when you ping it or run nslookup example.com, it resolves to an IP address, specifically

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.