Mobile app version of vmapp.org
Login or Join
BetL925

: Why do servers need to know their domain? Besides routing traffic, why do servers need to be configured with the server name? It seems like a waste in all cases except for routing or hosting

@BetL925

Posted in: #Apache #Httpd #Nginx #Server #WebHosting

Besides routing traffic, why do servers need to be configured with the server name?
It seems like a waste in all cases except for routing or hosting for a TLD.

Nginx example:

server {
listen 80;
server_name myexample.com
...
}


Apache also gives a warning Could not reliably determine the server's fully qualified domain name if you don't set the server name.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @BetL925

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry384

The main reason is: HTTP requests include the domain name. You could have stackoverflow.com and askubuntu.com all served off the same front end machine. When the server gets a request it needs to know what content it has to send. That's the main reason server configuration speaks about host name at all.

Why do you have to set it if you're only serving one domain? There's no strong reason, it's just a implementation decision in nginx. Other web servers may just answer for all host name by default, such as Python HttpServer.

A secondary reason is that the hostname may be used in error pages and we'd like it to be example.com not f1234.googlecloud.com.

10% popularity Vote Up Vote Down


 

@Nimeshi995

Sorry. But y'all have missed the point. It occurred to me that I may have been insulting with the previous sentence which was not what I wanted. so I am adding this: I like your answers. They are correct. But they missed some historical and general information in relation to having a host name and not necessarily having a domain name. Which is what I am trying to say here- albeit not as well as I would like.

Setting a host name for a server and as the question implies, for a web server, is simply to know, at minimum, what packets the server is to accept and respond to. Do not confuse the notion that a host name is for convenience only and that the IP address is the only important network setting. Not at all. Packet headers can be addressed with a host name, or domain name if Internet based, many more times than not if not exclusively.

When a request packet is made, often it is the host name or domain name that placed into the packet header. The address and routing information is secondary determined at another
network layer entirely and can change even while in route while the host name or domain name always remains the same short of a header rewrite via a proxy.

While it may seem trivial to add a host name and therefore not important, it is vitally important for networking and routing. This is why there are broadcasts on networks, to determine what host names have what IP addresses and MAC addresses and how to route any request to the right place. Again a packet is likely addressed by host name at minimum. Your router can now direct that request packet and your computer which then knows that packet is to be accepted and responded to.

Again, the host name is static addressing, while the IP address is, in network routing terms, dynamic addressing. Even when an IP address is statically assigned, in terms of network design, it is still a dynamic entity. It can be changed at any point.

I know some will argue with my premise, but often I see the concept reversed as it seems to be here. I am talking about network routing 101. Host names transcend all protocols while IP addresses do not. This means that no matter what network protocol is used, the host name remains the most important addressing mechanism. It just so happens that TCP/IP allows IP addressing at packet creation. I am not sure that such a mechanism exists in other protocols. I do not recall any.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme