Article ID: 2823, created on Oct 29, 2007, last review on May 9, 2014

  • Applies to:
  • Pro Control Panel Linux

AdditionalInformation

View Knowledge
Knowledge ID 2243
Product : Ensim Pro for Linux
Version : 3.5
Topic : Hotfix

Title
Adding unlimited automatic subdomains in Apache

Summary
Adding unlimited automatic subdomains in Apache

Prevention


Details
Adding unlimited automatic subdomains in Apache

Solution:

Note: Do not Apply this feature for Webppliance Pro 3.5, it already includes full fledged sub-domain support

If you want to allow Site Admins to create unlimited sub-domains (info.domain.com, sales.domain.com, etc.) for their domain (domain.com), without having to create additional virtual sites in WEBppliance, you can use a few extra Apache directives to support this feature.

The unlimited automatic domains feature will require 2 things:

  1. Wildcard DNS entry for this domain in the DNS server.

    So instead of:
    www IN A 123.123.123.4

    add or replace with:
    * IN A 123.123.123.4

    This will cause any hostname of the form "*.domain.com" to resolve to that IP address.

  2. Apache RewriteRules to redirect subdomain web traffic to a sub-directory. In WEBppliance, you can do this globally, via the customization files for each service.

    If you don't have a customization file yet for Apache (/usr/lib/python2.1/site-packages/vh3/custom/apache.py), create the apache.py file and paste this into it:


    import virthost
    def add_custom_directives(site, newconf, oldconf, cust):
    content = """
    ServerAlias *.%s
    RewriteEngine On
    RewriteCond %%{HTTP_HOST} .*.%s [NC]
    RewriteCond %%{HTTP_HOST} !%s [NC]
    RewriteRule ^/(.*)$ %s/var/www/html/%%{HTTP_HOST}/$1 [L]
    """ % (newconf['siteinfo']['domain'],newconf['siteinfo']['domain'],
    newconf['apache']['webserver'],
    virthost.domainfs_path(site))
    return content

When you add customizations to WEBppliance services, restart the GUI (/etc/rc.d/init.d/webppliance restart") so that any new sites created will be customized as you want. For existing sites, Edit and Save the site without making any changes, so that it's configs will get re-written.

Now all the Site Administrator has to do is create a new sub-directory in their /var/www/html/ (this is the path the Site Admin sees, not the real path in WEBppliance) with the name of the sub-domain. For example, if you want two new subdomains "sales.domain.com" and "info.domain.com", create these directories:

/var/www/html/sales.domain.com/
/var/www/html/info.domain.com/

Upload the contents for those web sites into their respective sub-directories.


For details on how to add these custom directives to Apache in WEBppliance see the KB/FAQ entry titled "Customizing virtual domain services (Apache directives, configs, etc.)."


Attachments


Related Knowledge

Related Links
 
Last ModifiedUsageSatisfiedLast Used
6/16/2006 2:01:20 AM28 10/11/2007 1:50:10 AM

4cc899da08664637a8bc437308d3ddd7 3ccb419cf98083f3bb45808fba8dbc7c 6311ae17c1ee52b36e68aaf4ad066387

Email subscription for changes to this article
Save as PDF