1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Trying to set up wildcard DNS, not working

Discussion in 'Site & Server Administration' started by briandunning, Jun 16, 2005.

  1. #1
    I have a virtual dedicated server (Red Hat) at GoDaddy and I'm trying to set up wildcard DNS. In short, I want:
    anything.mydomain.com/thepage.html
    to resolve to:
    mydomain.com/thepage.html

    I've taken the following steps:
    1. Using Plesk, I created an A record to point *.mydomain.com to the IP address.
    2. I created a file at /home/httpd/vhosts/mydomain.com/conf/vhost.conf and it contains the following text, nothing more:
    ServerAlias *.mydomain.com
    3. Using SSH, I logged in as root and ran the following command:
    # /usr/local/psa/admin/bin/websrvmng -a -v
    4. I rebooted the machine.

    And now:
    anything.mydomain.com/thepage.html gives a 404 error.
    anything.mydomain.com produces the Plesk default page.
    mydomain.com - all pages work fine.

    Did I do something incorrectly, or are there missing steps I didn't take? Thanks!

    (If someone wants to see the actual page, the domain is 04planet.info and a page that works is 04planet.info/random.1.html)
     
    briandunning, Jun 16, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your problem is that the browser sends the Host header derived from the URL. If your web server is configured to use virtual domains, the website will be chosen based on the Host header and since in your case it's anything.04planet.info, your main website (04planet.info) is not found. Remove this host association (i.e. just make the website to listen on this IP address) and everything will work just fine.

    J.D.
     
    J.D., Jun 16, 2005 IP
  3. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #3
    Thanks JD - I'm not exactly sure I follow you - how would I go about trying what you suggest?
     
    briandunning, Jun 16, 2005 IP
  4. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm saying that you have a virtual host set up - a website that is identified by two pieces of the information, the IP address and the Host header. You need to set up a website that simply listens on the IP address and ignores the Host header. Here's some info for Apache:

    http://httpd.apache.org/docs-2.0/vhosts/name-based.html

    Look for ServerName in the main configuration file. Try removing it and see what happens.

    J.D.
     
    J.D., Jun 16, 2005 IP
  5. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #5
    You need to set up the following line in your httpd.conf:
    ServerName www.yourdomain.com
    ServerAlias *.yourdomain.com

    Not sure how to do it in plesk, but you can edit your virtual host configuration file directly on your server.
    You probably have ServerName in there, you just need to add ServerAlias right below it.
     
    nevetS, Jun 16, 2005 IP
  6. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #6
    Makes sense to me. But since this is a virtual dedicated server - meaning other people use it too - is it possible that I don't have access to that main httpd.conf file? Where exactly would I find it in the directories?
     
    briandunning, Jun 16, 2005 IP
  7. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #7
    I have one server using plesk, and if I ssh in, the conf file for a particular vhost is actually located in:
    /home/httpd/vhosts/hostname.com/conf/httpd.include

    By the way, that's apache 1.39 syntax - not sure if it changes with apache 2

    With a virtual dedicated server, you should be running your own apache (so when yours crashes, others are not affected) so you should still be able to find and edit this file.
     
    nevetS, Jun 16, 2005 IP
  8. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #8
    That's actually the same thing as putting it into:
    /home/httpd/vhosts/<domainname>/conf/vhost.conf
    if I am correct. I had already done this. I also just tried it by adding it into httpd.include, and neither makes any difference. Results still the same as noted above. Any other ideas?

    Thanks for all the feedback, BTW. :)
     
    briandunning, Jun 16, 2005 IP
  9. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #9
    JD - I tried completely removing the ServerName line, and that made the main site resolve to the Plesk default page. So no help there. :(
     
    briandunning, Jun 16, 2005 IP
  10. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #10
    Well, this may take a little bit deeper troubleshooting and looking into plesk.

    First off, did you restart apache after you made the changes to the configuration file? Apache loads the configuration file only once at startup.

    other troubleshooting steps:
    1) verify that you've made the changes to the right file. Make another change to that file that you would be able to notice right away. Maybe change the root directory to a test site, or configure a virtual directory. Something just to verify that your editing the right file.
    2) verify dns is working as expected. Just ping alfred.yourdomain.com to make sure it's going to the right IP address.
    3) it could be that a different wildcard entry exists for that IP address higher up in the configuration file. That makes things difficult for you. If that's the case, you need to find that other wildcard entry and edit it somehow to account for your configuration, or move your wildcard entry to above that location.

    I have done this in the past where I have www. mydomain.com, forums.mydomain.com, and *.mydomain.com all pointing to different directories. forums.mydomain.com works only when configured above the wildcard, since apache processes things in order.

    The server name and server alias need to be inside the <VirtualHost 1.1.1.2:80> tag, preferably near the top.
     
    nevetS, Jun 16, 2005 IP
  11. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I didn't realize that you were using an include config file. I did a quick test and here's how it works in my environment (a dedicated server). If I have multiple VirtualHost directives and the host supplied in HTTP doesn't match any ServerName's in any of them, Apache uses the *first* VirtualHost in the order they appear in the config file. If the Host header matches any of the ServerName's, this VirtualHost is used. ServerAlias doesn't seem to do anything regarding any of this in my test. So, it seems that whatever page you get when the host doesn't match is what is served by the first VirtualHost section in your global config file (the one that includes yours).

    J.D.
     
    J.D., Jun 16, 2005 IP
  12. pmg2007

    pmg2007 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thanks for your help everyone! I set up wildcard dns for my dedicated server. nevetS is correct change the httpd.include a lot of material out there does not say this they mention creating a vhosts.conf.
     
    pmg2007, Mar 14, 2008 IP