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:
- 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.
- 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.)."
|