..and a cupful of serverside configuration goodness…

Debugging isnt fun….
But it does have its moments, when you feel you have learnt something new.Like today….

First let me step back a bit and explain ip-domain mapping using host files on Windows. The Hosts file contains the mappings of IP addresses to host names. This file is loaded into memory (cache) at startup, then Windows checks the Hosts file before it queries any DNS servers, which enables it to override addresses in the DNS.[1] The host file is located at ‘C:WINDOWSsystem32driversetchosts’.

Typically, during development, I use host files to map urls for applications under development to the sub-domain of my main site. This allows me to access cookies etc while still running the web-app on my laptop.

While setting up an web-app today I mapped a domain to an ip using my host file, but could not bring the page up no matter how I hard tried. At my wit’s end I called upon our sys-admin and resident Solaris proponent to help me fix this problem. A couple of hours later I was on my way and had a much deeper understanding of server configuration stuff. Before I forget what I learned I figured I may as well save it for posterity by publishing it here.

The problem arose because I was trying to map my domain to an ip of a virtual server. While this is not a big deal (click here to see how Apache does it), there was something weird happening on my machine.
Typically servers, like regular computers, have physical interfaces that connect them to the network. However you can have multiple virtual interfaces each with individually assigned IP addresses on a single physical interface. Within the webserver software, listening sockets were defined and mapped to the IP addresses on our virtual interfaces.
Each of the virtual interfaces are associated with a listening socket and every virtual server instance is bound to that listening socket. Virtual servers themselves can be name based or ip based. IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve whereas name based ones use DNS mappings of IPs to decide which host to serve

The behavior I was seeing turned out to be because while the server’s virtual server instances were bound to individual IP addresses, there were also names that identified what was allowed in the host request field sent by a browser. Since I defined a name in my local hosts file that didn’t match a name defined on the server to be associated with the virtual server instance that I tried to reach, the web server sent my browser’s request to its default, or primary instance.

…I am glad its a Friday !

..and a cupful of serverside configuration goodness…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s