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.

  • 2
    Mostly it's for virtual hosts where one web server is hosting multiple domain names. Apr 24 '14 at 19:13
  • I think that with cloud computing the paradigm is shifting. Now it's probably more common to have multiple web servers hosting one domain. Hopefully future software releases will keep that in mind so I can sleep better at night
    – Stephen
    Apr 24 '14 at 19:19
  • Actually, more used for shared hosting, which has been around for well over a decade. Cloud computing would generally have less use for virtual hosting within a web server because the OS is typically virtualized at the machine level, rather than at the web server level. Apr 24 '14 at 19:29
  • True. My thinking was leaning towards scaling websites. I just wish nginx, apache et al would start catering to the cloud computing niche a bit more
    – Stephen
    Apr 25 '14 at 17:56
  • @Stephen It's completely OK to have the same http server name on any number of servers for that domain. Why are you losing sleep?
    – poolie
    Apr 26 '14 at 0:12

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.

  • A: it's just an implementation decision
    – Stephen
    Apr 25 '14 at 18:00

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.

  • No. You are deeply confused about the difference between layers 2, 3 and 4. Host name are resolved using DNS, not ARP broadcasts. Packets are not addressed by host name. HTTP host name are a different thing again.
    – poolie
    Apr 24 '14 at 22:17
  • With respect. That is only half of the equation. Think about your browser. You enter the domain name and a request packet is created with that domain name which is not resolved to an IP address by the browser. That is what I am talking about. Host names (not domain names) are the center of networking traditionally. Forgetting the technical stuff and going back before TCP/IP, all networks relied upon the host name first. I was not talking about TCP/IP exclusively at all. I was not even necessarily talking about domain names. I was talking more historically. I may not have said that very well.
    – closetnoc
    Apr 25 '14 at 0:59
  • Browsers absolutely do resolve the host name to an IP address (except in unusual configurations), and http runs on tcpip. NETBIOS or whatever you're remembering as name based networking is not relevant.
    – poolie
    Apr 26 '14 at 0:16
  • I did not say that browsers resolved addresses! I coded protocol stacks, device drivers, and parts of various OS(s) for ARPA NET and now for 30 years. I know how TCP/IP works along with more than a dozen other protocols. I am not a noob. You need to reread what I have written. What I have written is that the Host Name (NOT DOMAIN NAME) is the single most important network data element since the beginning of networking. This is because the addressing schemes of networking before and for TCP/IP centered around the host name which is static. All other addressing was non-static.
    – closetnoc
    Apr 26 '14 at 0:35

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.