Michael Worsham
asked on
Dynamic virthosts
Here is the issue.
We are working on giving our developers a 'sandbox' where they can create new sites under a base directory structure we have setup for them. The problem is the sites change from day to day, based on their site name and its a real issue for us to have to keep modifying the virthosts-sandbox.conf file for each site name change.
Listen 123.456.789.012:80
VirtualHost dev.mysite.com>
ServerName dev.mysite.com
DocumentRoot /web/sandbox.domainname.co m/dev.mysi te.com/htd ocs
ErrorLog /var/web/sandbox.domainnam e.com/dev. mysite.com _error_log
CustomLog /var/web/sandbox.domainnam e.com/dev. mysite.com _access_lo g common
ScriptAlias /cgi-bin/ "/web/sandbox.domainname.c om/dev.mys ite.com/cg i-bin/"
<Directory /web/sandbox.domainname.co m/dev.mysi te.com>
Options Indexes FollowSymLinks Multiviews +Includes
AllowOverride All
</Directory>
</VirtualHost>
Is it possible to use the Rewrite Engine (or any other module) to just direct the site instead, based on what the DNS entry is seen as? Our DNS points each site to a CNAME like: sandbox.domainname.com
Example:
- dev.mysite.com would point to /web/sandbox.domainname.co m/dev.mysi te.com
- dev2.mysite.com would point to /web/sandbox.domainname.co m/dev2.mys ite.com
And so on.
We just don't want to have to keep modifying the virthosts-sandbox.conf for each new domain name being addressed. We are talking about several hundred sites found in the virthosts-sandbox.conf file, thus the reason for the request.
Apache Version: 2.0.52 (Red Hat)
PHP Version 5.1.2
Loaded Modules: core prefork http_core mod_so mod_access mod_auth mod_auth_anon mod_auth_dbm mod_auth_digest util_ldap mod_auth_ldap mod_include mod_log_config mod_env mod_mime_magic mod_cern_meta mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_asis mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_imap mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy proxy_ftp proxy_http proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi mod_php5 mod_ssl
-- Michael
We are working on giving our developers a 'sandbox' where they can create new sites under a base directory structure we have setup for them. The problem is the sites change from day to day, based on their site name and its a real issue for us to have to keep modifying the virthosts-sandbox.conf file for each site name change.
Listen 123.456.789.012:80
VirtualHost dev.mysite.com>
ServerName dev.mysite.com
DocumentRoot /web/sandbox.domainname.co
ErrorLog /var/web/sandbox.domainnam
CustomLog /var/web/sandbox.domainnam
ScriptAlias /cgi-bin/ "/web/sandbox.domainname.c
<Directory /web/sandbox.domainname.co
Options Indexes FollowSymLinks Multiviews +Includes
AllowOverride All
</Directory>
</VirtualHost>
Is it possible to use the Rewrite Engine (or any other module) to just direct the site instead, based on what the DNS entry is seen as? Our DNS points each site to a CNAME like: sandbox.domainname.com
Example:
- dev.mysite.com would point to /web/sandbox.domainname.co
- dev2.mysite.com would point to /web/sandbox.domainname.co
And so on.
We just don't want to have to keep modifying the virthosts-sandbox.conf for each new domain name being addressed. We are talking about several hundred sites found in the virthosts-sandbox.conf file, thus the reason for the request.
Apache Version: 2.0.52 (Red Hat)
PHP Version 5.1.2
Loaded Modules: core prefork http_core mod_so mod_access mod_auth mod_auth_anon mod_auth_dbm mod_auth_digest util_ldap mod_auth_ldap mod_include mod_log_config mod_env mod_mime_magic mod_cern_meta mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_asis mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_imap mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy proxy_ftp proxy_http proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi mod_php5 mod_ssl
-- Michael
ASKER
Actually that is what we are looking to do as seen in the original question, but don't know what we need to do with the mod_rewrite to pass the site to that address. Is it possible to have something like a /web/sandbox.domainname.co m/$request ed_url/htd ocs in the Virthosts * entry or ?
Web Browser URL --> dev.mysite.com
DNS sees the request for dev.mysite.com and resolves it to sandbox.domainname.com
Linux Apache/PHP instance sees a request for dev.mysite.com and points the user to /web/sandbox.domainname.co m/dev.mysi te.com/htd ocs
The type of sites that are being built out are Joomla and Drupal sites.
Web Browser URL --> dev.mysite.com
DNS sees the request for dev.mysite.com and resolves it to sandbox.domainname.com
Linux Apache/PHP instance sees a request for dev.mysite.com and points the user to /web/sandbox.domainname.co
The type of sites that are being built out are Joomla and Drupal sites.
funny, we do the same mass production with joomla and drupal.
so are your virtual sites arent working at all? your hostname never changes right? so you have http://thisdoesntchange.thisdoesnteaither.com/thischangesallthetime/?
so are your virtual sites arent working at all? your hostname never changes right? so you have http://thisdoesntchange.thisdoesnteaither.com/thischangesallthetime/?
ASKER
Right now we have the following built out as out virthosts-sandbox.conf:
NameVirtualHost 111.222.333.444
Listen 111.222.333.444:80
<VirtualHost 111.222.333.444>
ServerName sandbox.domainname.com
DocumentRoot /web/sandbox.domainname.co m
ErrorLog /var/web/sandbox.domainnam e.com/erro r_log
CustomLog /var/web/sandbox.domainnam e.com/acce ss_log common
ScriptAlias /cgi-bin/ "/web/sandbox.domainname.c om/"
<Directory /web/sandbox.domainname.co m>
Options Indexes FollowSymLinks Multiviews +Includes
AllowOverride All
</Directory>
RewriteEngine on
RewriteRule ^(.*)$ http://sandbox.domainname.com/$1 [L,R]
</VirtualHost>
We just don't know where to go from here as we have always built out sites, placing their name in the VirtHosts entry (i.e. <VirtHosts dev.mysite.com>, etc).
NameVirtualHost 111.222.333.444
Listen 111.222.333.444:80
<VirtualHost 111.222.333.444>
ServerName sandbox.domainname.com
DocumentRoot /web/sandbox.domainname.co
ErrorLog /var/web/sandbox.domainnam
CustomLog /var/web/sandbox.domainnam
ScriptAlias /cgi-bin/ "/web/sandbox.domainname.c
<Directory /web/sandbox.domainname.co
Options Indexes FollowSymLinks Multiviews +Includes
AllowOverride All
</Directory>
RewriteEngine on
RewriteRule ^(.*)$ http://sandbox.domainname.com/$1 [L,R]
</VirtualHost>
We just don't know where to go from here as we have always built out sites, placing their name in the VirtHosts entry (i.e. <VirtHosts dev.mysite.com>, etc).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't think its possible to comment out the Listen portion as we have several other httpd's running on the same box for other departments.
I tried to modify the NameVirtualHost, and I get this error upon '/etc/init.d/http-sandbox configtest':
[Thu Aug 09 08:31:14 2007] [error] VirtualHost _default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
I tried to modify the NameVirtualHost, and I get this error upon '/etc/init.d/http-sandbox configtest':
[Thu Aug 09 08:31:14 2007] [error] VirtualHost _default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
ASKER
Nevermind. I got that part working. Had to modify one other file.
Now I just need the Rewrite Cond and Rules. Currently I have (which is probably not right):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+)\.sandbox\.domain name\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://sandbox.domainname.com/$1/htdocs [R]
I just need the path to resolve to http://sandbox.domainname.com/mysitename.com.
Now I just need the Rewrite Cond and Rules. Currently I have (which is probably not right):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+)\.sandbox\.domain
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://sandbox.domainname.com/$1/htdocs [R]
I just need the path to resolve to http://sandbox.domainname.com/mysitename.com.
ASKER
Also posted this message on another site (http://forum.modrewrite.com) and someone posted about using mod_vhost_alias instead to do what I was looking for. After a bit of research, I stumbled upon this site:
http://eising.wordpress.com/2006/05/01/using-mod_vhost_alias-and-normal-virtualhosts-on-the-same-time/
-- M
http://eising.wordpress.com/2006/05/01/using-mod_vhost_alias-and-normal-virtualhosts-on-the-same-time/
-- M
I've messed with this on my development servers a bunch and i've found that the new folder method is the simplest and does what i need it to do. just a thought.