Product:
Search Type:

Adding unlimited automatic subdomains in Apache

Article ID: 2823 
Last Review: Oct,29 2007
APPLIES TO:
  • Parallels Pro Control Panel Linux

Additional information

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 %% .*.%s [NC]

    RewriteCond %% !%s [NC]

    RewriteRule ^/(.*)$ %s/var/www/html/%%/$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

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
*Please type the code you can see.
* - required fields