0

In this tutorial it is written that after matching against the listen directive, nginx will match agains the server_name directive, which can be either an ip adress or a domain name.

But how will it ever be called when you use a domain name? When I go to my browser and write http://myserver/, this will go the DNS server of my ISP and will tell me that there is no http://myserver/ anywhere to be found.

How does it work?

2 Answers 2

3

When you type http://myserver/ in your browser, you will ask the DNS server to resolve name myserver to IP address. Then, the browser will connect to one of the returned IP address(es).

The name myserver will be passed along with HTTP request as Host: myserver header. This is how things work generally not specific to nginx.

1

There is a file, /etc/hosts , you need to add your domain name there and the IP address corresponding to it.

sudo vim /etc/hosts

(vim or your text editor)

hosts file will open.

192.168.122.245 nagios.monitor.com
192.168.122.245 localhost
192.168.122.245 www.netdatamonitor.com  netdatamonitor.com
127.0.0.1       www.newgmap.com
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

(192.168.122.245 is my pc's IP)

This is my file. You should add your domain name there and it should work then if you dont have any other issues.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .