Results 1 to 3 of 3

Thread: Default vhost for dedicated IP address

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    2
    cPanel/WHM Access Level

    Root Administrator

    Default Default vhost for dedicated IP address

    Seems many of the questions here are about default vhosts, but I have looked and am unable to find an answer for this one. The following similar questions didn't get any answers:

    Dedicated IP address default virtual host
    http://forums.cpanel.net/f5/make-apa...host+dedicated

    On my server, to which I have root access, I have assigned a dedicated IP address to a couple of subdomains by following the instructions at Assigning Dedicated IPs to Subdomains.

    This is working fine, but unlike my main shared IP address, which defaults to the default vhost template when accessed through anything other than the configured domain names, I've noticed that the dedicated IP defaults to the the vhost of one of the two subdomains I've assigned to it. (It was a bit of a shock to discover that some random 3rd party dns entry that happened to be set to the same IP address had started showing up in google with my website contents )

    Is there any way to set the default vhost for a dedicated IP address? A way that uses the cpanel config files rather than editing the generated httpd.conf would obviously be preferable, but if httpd.conf has to be edited, what's the best way to do it?

  2. #2
    Registered User
    Join Date
    Nov 2011
    Posts
    2
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Default vhost for dedicated IP address

    Sorted it out. Posting here in case anybody else has the same problem.

    I copied /var/cpanel/templates/apache2/main.default to /var/cpanel/templates/apache2/main.local and edited the new copy, main.local.

    I found the following lines.

    Code:
    [%- FOREACH nvh IN namevirtualhosts -%]
    NameVirtualHost [% nvh %]
    [% END -%]
    NameVirtualHost *
    After these lines, I added the following, replacing myip with the dedicated IP address and /some/folder with a nonexistent folder (as I want a 404 if anyone access the site other than through the proper domain name):

    Code:
    <VirtualHost myip:80>
      DocumentRoot /some/folder
    </VirtualHost>
    I then ran the following commands to rebuild the apache config and restart the server.

    Code:
    /usr/local/cpanel/scripts/rebuildhttpdconf
    /usr/local/cpanel/scripts/restartsrv_apache
    Seems to work, though it seems a shame to have to copy the main template to do something so simple. Perhaps someone knows a better way...?

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    1

    Default Re: Default vhost for dedicated IP address

    thanks, it works like a charm

Similar Threads

  1. Change Default vHost
    By indoc0der in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 09-11-2011, 10:49 PM
  2. Default Vhost
    By PickMonitor in forum cPanel & WHM Discussions
    Replies: 6
    Last Post: 10-11-2010, 02:42 PM
  3. Dedicated IP address default virtual host
    By xous in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 11-08-2008, 07:52 PM
  4. easyapache, serversignature, default vhost, etc
    By fred123123 in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 01-03-2008, 02:07 PM