The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

unhosted domain pointed at server leads to first account not /usr/local/apache/htdocs

Discussion in 'EasyApache' started by boatdesign, Feb 26, 2009.

  1. boatdesign

    boatdesign Well-Known Member

    Joined:
    Sep 13, 2003
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    16
    New whm/cpanel server has one weird thing:
    if someone points a domain at the main namebased hosting IP and there is no account setup for it, it loads the first-created namebased site (i.e. it loads /home/account1/www/)

    So if you remove an account and they're doing their own dns, now that domain shows another account. It should show the default page at /usr/local/apache/htdocs/index.html

    In the httpd.conf whm builds this:
    <VirtualHost *>
    ServerName hostname.mydomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin email removed
    </VirtualHost>

    If I change it to
    <VirtualHost main.server.ip.number:80>
    ServerName hostname.mydomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin email removed
    </VirtualHost>
    it works as I expect it should (if a domain is pointed at the server's namebased IP and it's not created yet or deleted, it shows the default server page not another account.)

    In the old days I would edit the httpd.conf to change something like this, but now with easyapache I need some direction on how to fix this so it doesn't get unchanged the next time apache is built. Many thanks in advance.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  3. boatdesign

    boatdesign Well-Known Member

    Joined:
    Sep 13, 2003
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    16
    Thanks Infopro.

    Searching the docs, it seems simply editing /var/cpanel/templates/apache1/main.default makes it easy to make the change stick.

    Edit: something else seems to be in play here -- maybe a bad apache build last time even though I did not see any errors.

    It struck me as odd that the way it worked and the way the comment tag implied it should work were in conflict, so I tried backing it out and rebuilding a third time and now it works as designed and in practice I think.

    In the generated httpd.conf I now have

    # DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
    NameVirtualHost main-server-ip:80
    NameVirtualHost *
    # DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

    <VirtualHost main-server-ip:80>
    ServerName hostname.servername.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin removed
    </VirtualHost>


    # Default vhost for unbound IPs

    <VirtualHost *>
    ServerName hostname.serverdomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin removed
    </VirtualHost>

    The top section was not there before... weird.
     
    #3 boatdesign, Feb 26, 2009
    Last edited: Feb 26, 2009
Loading...

Share This Page