[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-users] RE: Apache subdomains (aliases)



-----Original Message-----
Is there any way to configure the cobalt to accept *.domain.com for the web
server, rather than having to add each subdomain as a seperate alias?
-----Original Message-----

Okay, this is how you do what you would like to do.

Step #1 - Setup 'wildcard' DNS entry in your zone file

*	IN	PTR	1.1.1.1

Step #2 - Add the following line to your "/etc/httpd/conf/httpd.conf"
I like to put it near the end of the list, but, I do not think that it
matters.

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Step #3 - The fun part.  Generally I like to add a virtual host and 
give it a unqiue IP address in the Cobalt GUI.  For instance, on a RaQ 
550, since it builds virtual site config files, it makes it easier.  
So, lets say I create the following site via the GUI:

host.domain.tld -> 1.1.1.1 

No other sites have that IP address, (they can, but in this example,
they do NOT).

Now, lets edit your "/etc/httpd/conf/vhost/siteX" file.  It should
look like the following:


#------------------ start of file ------------------

# owned by VirtualHost
NameVirtualHost 1.1.1.1

# FrontPage needs the following four things to be here
# otherwise all the vhosts need to go in httpd.conf, which could
# get very large since there could be thousands of vhosts
Port 80
ServerRoot /etc/httpd
ResourceConfig /etc/httpd/conf/srm.conf
AccessConfig /etc/httpd/conf/access.conf

<VirtualHost 1.1.1.1>
ServerName host.domain.com
ServerAdmin admin
DocumentRoot /home/.sites/130/site44/web
ErrorDocument 401 /error/401-authorization.html
ErrorDocument 403 /error/403-forbidden.html
ErrorDocument 404 /error/404-file-not-found.html
ErrorDocument 500 /error/500-internal-server-error.html
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^1.1.1.1(:80)?$
RewriteCond %{HTTP_HOST}                !^host.domain.com(:80)?$ [NC]
RewriteRule ^/(.*)                      http://host.domain.com/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))?
/home/.sites/130/site44/users/$1/web/$3
# BEGIN WebScripting SECTION.  DO NOT EDIT MARKS OR IN BETWEEN.
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
# END WebScripting SECTION.  DO NOT EDIT MARKS OR IN BETWEEN.
</VirtualHost>

#------------------ end of file ------------------

That is what your file will look like

Now, you will need to add the following, before the "<VirtualHost 1.1.1.1>"
option.  If you do NOT add it there, it will NOT work

#------------------ start of file ------------------

<VirtualHost 1.1.1.1:80>
UseCanonicalName Off
ServerAdmin admin
VirtualDocumentRoot /home/.sites/130/site44/virtual_hosts/%1/
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
AddHandler server-parsed .shtml
AddType text/html .shtml
<Directory /home/.sites/130/site44/virtual_hosts/>
AllowOverride Options FileInfo
Options ExecCGI
</Directory>
</VirtualHost>

#------------------ end of file ------------------


Step #4 - You will need to create 1 directory to make this
possible:

mkdir /home/sites/host.domain.tld/virtual_hosts


Step #5 - When you want to have a virtual site, you will just need
to create a directory inside of that "virtual_hosts" folder.  The
DNS will resolve everything to your 1 IP address, and Apache will
use that folder as the "root" directory.

That should just about do it.  Make sure to "reload" your httpd &
name daemon so that the changes take effect.

BTW, I had posted a way to do it on a RaQ 4 a long time ago, so I
know it is in the archives.  Search for "tripod raq4 howto" or some
thing like that.  I believe that is what I had called it.  

Let us know how it goes for you!

Sincerely,

Brian N. Smith