-2

If I type in my server ip address into a browser, it always goes to the lowest alphabetical domain on my server. So if I had these domain on my server:

  • zty.com
  • typ.com
  • dfo.com

...typing in the ip would take you to dfo.com.

If I then add abc.com to my server, typing the the ip in a browser would go to abc.com

How do I make the ip go to the primary domain on the server?

0

1 Answer 1

6

By using an IP address to access your server you are bypassing the DNS system so this has nothing to do with DNS or Bind.

If you are observing this as the response from a web server and the webserver is apache then my guess is that you are creating vhosts in such a manner that they are defined alphabetically. Without any way to differentiate between vhosts apache will serve the first vhost that was defined as the default vhost.

What you have to do is make your primary domain be defined as the first vhost on the server. If your primary domain is example.com and it is defined in a file called example.com rename the example.com configuration file to something like 000example.com

4
  • What does it have to do with then, and how would I fix it? May 12, 2012 at 7:14
  • Would your idea be better than a2ensite'ing default again, and putting the same DocumentRoot/Directory path as the primary domain? May 12, 2012 at 7:30
  • 1
    Creating a file which obviously comes first alphabetically is the way this is normally handled. Apache picks the first file it can find if the client connects via IP not name - just make your primary domain config file the first one alphabetically, as suggested. May 12, 2012 at 7:33
  • To clarify this comment a bit, Apache picks the first <NameVirtualHost> it finds for an IP Address that's using name-based virtual hosting. On systems using sites-enabled or a similar directory the contents of that directory are loaded in "ASCIIbetical order" (the order they show up in when you run ls). So the file that's first in the directory listing is loaded earliest, and "wins" by default.
    – voretaq7
    Mar 7, 2013 at 16:28

You must log in to answer this question.

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