Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Sharing configuration between multiple virtual hosts

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Next:  help with http.conf hacking  
Author Message
machuidel

External


Since: Oct 20, 2003
Posts: 1



(Msg. 1) Posted: Mon Oct 20, 2003 7:49 pm
Post subject: Sharing configuration between multiple virtual hosts
Archived from groups: alt>apache>configuration (more info?)

My current configuration of Apache has several name-based virtual hosts
(2 for each domain). One for use with SSL (Port 443) and one for use
without (Port 80).

The problem is that the configuration for all different domains is
exactly the same, except for the ServerName, ServerAdmin, ServerAlias
and DocumentRoot directives. Is there a way I can share the
configuration between multiple virtual hosts?

Here is a copy of my virtual host configuration (of course the domains
were changed):

----------BEGIN----------

NameVirtualHost *:80
NameVirtualHost *:443

#
# Virtual host (domain1.com)
#
<VirtualHost *:80>
ServerName www.domain1.com
ServerAdmin webmaster.TakeThisOut@domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot /home/www/domain1.com

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192\.168\.0\.[0-9]+$
RewriteCond %{REQUEST_URI} ^/intranet.*$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]

<Directory "/home/www/domain1.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /home/www/domain1.com/intranet>
AuthType Basic
AuthName "Intranet"

AuthPAM_Enabled on
AuthPAM_FallThrough off

Order deny,allow
Deny from all
Allow from 192.168.0.0/24
Require valid-user
Satisfy all
</Directory>
</VirtualHost>

<VirtualHost *:443>
ServerName www.domain1.com
ServerAdmin webmaster.TakeThisOut@domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot /home/www/domain1.com

SSLEngine on

SSLCACertificateFile conf/ssl.crt/ca.crt
SSLCertificateKeyFile conf/ssl.key/server.key
SSLCertificateFile conf/ssl.crt/server.crt

<Directory "/home/www/domain1.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /home/www/domain1.com/intranet>
SSLVerifyClient optional
SSLVerifyDepth 1
SSLOptions +FakeBasicAuth +StrictRequire
SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128

AuthType Basic
AuthName "Secured Intranet"

AuthPAM_Enabled on
AuthPAM_FallThrough off

Order deny,allow
Deny from all
Require valid-user
Satisfy any
</Directory>
</VirtualHost>

#
# Virtual host (domain2.com)
#
<VirtualHost *:80>
ServerName www.domain2.com
ServerAdmin webmaster.TakeThisOut@domain2.com
ServerAlias domain2.com *.domain2.com
DocumentRoot /home/www/domain2.com

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192\.168\.0\.[0-9]+$
RewriteCond %{REQUEST_URI} ^/intranet.*$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]

<Directory "/home/www/domain2.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /home/www/domain2.com/intranet>
AuthType Basic
AuthName "Intranet"

AuthPAM_Enabled on
AuthPAM_FallThrough off

Order deny,allow
Deny from all

Allow from 192.168.0.0/24
Require valid-user
Satisfy all
</Directory>
</VirtualHost>

<VirtualHost *:443>
ServerName www.domain2.com
ServerAdmin webmaster.TakeThisOut@domain2.com
ServerAlias domain2.com *.domain2.com
DocumentRoot /home/www/domain2.com

SSLEngine on

SSLCACertificateFile conf/ssl.crt/ca.crt
SSLCertificateKeyFile conf/ssl.key/server.key
SSLCertificateFile conf/ssl.crt/server.crt

<Directory "/home/www/domain2.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /home/www/domain2.com/intranet>
SSLVerifyClient optional
SSLVerifyDepth 1
SSLOptions +FakeBasicAuth +StrictRequire
SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128

AuthType Basic
AuthName "Secured Intranet"

AuthPAM_Enabled on
AuthPAM_FallThrough off

Order deny,allow
Deny from all
Require valid-user
Satisfy any
</Directory>
</VirtualHost>

----------END----------

Thank you
Mike Machuidel

 >> Stay informed about: Sharing configuration between multiple virtual hosts 
Back to top
Login to vote
user2518

External


Since: Oct 20, 2003
Posts: 8



(Msg. 2) Posted: Tue Oct 21, 2003 2:05 pm
Post subject: Re: Sharing configuration between multiple virtual hosts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Mike Machuidel wrote:
 > The problem is that the configuration for all different domains is
 > exactly the same, except for the ServerName, ServerAdmin, ServerAlias
 > and DocumentRoot directives. Is there a way I can share the
 > configuration between multiple virtual hosts?

There must be better solutions but this one might work:

<VirtualHost *:80>
ServerName <a style='text-decoration: underline;' href="http://www.domain1.com" target="_blank">www.domain1.com</a>
ServerAdmin webmaster DeleteThis @domain1.com
ServerAlias domain1.com *.domain1.com
Include foo/site1.conf
</VirtualHost>

<VirtualHost *:443>
ServerName <a style='text-decoration: underline;' href="http://www.domain1.com" target="_blank">www.domain1.com</a>
ServerAdmin webmaster DeleteThis @domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot /home/www/domain1.com
Include foo/domain1.conf
</VirtualHost><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Sharing configuration between multiple virtual hosts 
Back to top
Login to vote
user2518

External


Since: Oct 20, 2003
Posts: 8



(Msg. 3) Posted: Tue Oct 21, 2003 2:07 pm
Post subject: Re: Sharing configuration between multiple virtual hosts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Mike Machuidel wrote:

  > The problem is that the configuration for all different domains is
  > exactly the same, except for the ServerName, ServerAdmin, ServerAlias
  > and DocumentRoot directives. Is there a way I can share the
  > configuration between multiple virtual hosts?


There must be better solutions but this one might work:

<VirtualHost *:80>
ServerName <a style='text-decoration: underline;' href="http://www.domain1.com" target="_blank">www.domain1.com</a>
ServerAdmin webmaster DeleteThis @domain1.com
ServerAlias domain1.com *.domain1.com
Include foo/domain1.conf
</VirtualHost>

<VirtualHost *:443>
ServerName <a style='text-decoration: underline;' href="http://www.domain1.com" target="_blank">www.domain1.com</a>
ServerAdmin webmaster DeleteThis @domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot /home/www/domain1.com
Include foo/domain1.conf
</VirtualHost>


An place all common config in a file called foo/domain1.conf<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Sharing configuration between multiple virtual hosts 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Multiple and separate SSL Virtual hosts - Ok. I have in my httpd.conf: ------------------- Listen 80 Listen 443 <VirtualHost 1.2.3.4:80> ServerName www.xyz.com DocumentRoot /home/apache/www.xyz.com </VirtualHost> <VirtualHost 1.2.3.5:80> ServerName www.a...

Multiple sets of dynamic virtual hosts - Hi. I have a bunch of virtual hosts like this: site1.john.company.com site2.john.company.com site3.john.company.com site1.paul.company.com site2.paul.company.com site3.paul.company.com I would like to use dynamic virtual hosting so I can jus...

very strange... multiple name based virtual hosts seem to .. - Hi there, It is said overall that multiple name based virtual hosts can't work with ssl (see for example http://httpd.apache.org/docs-2.0/ssl/ssl_faq.html#vhosts), but surprisingly I got it work with apache 2... From conf.d/ssl.conf: ..

Multiple Webalizer configs for Apache virtual hosts? - Apologies if this is the wrong group to ask this - I couldn't find a specific group for webalizer. I've set up a virtual hosts, with a CustomLog file, and I want to configure Webalizer to process that log, and place the output in a different place from...

anyone have multiple virtual hosts over SSL working on Ubu.. - I have been fighting my Apache2 config for months trying to get multiple virtual hosts working over SSL. Does anyone have this working for Ubuntu 7.10? I'd love to see how you've done it. Cheers, Scott
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]