DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Apache Configuration For 1 Application Serving Requests From Mulitple (4) Domains
// One rails application serving 4 domains via mongrel + apache2.2 proxy
#
# Proxy Server directives. Uncomment the following lines to
# enable the proxy server:
#
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
#ProxyPass / http://127.0.0.1:8000/dl
#ProxyPassReverse / http://127.0.0.1:8000/dl
#ProxyPreserveHost On
</IfModule>
# End of proxy directives.
Listen 8080
<VirtualHost *:8080>
<Location />
SetHandler balancer-manager
Deny from all
Allow from localhost
</Location>
</VirtualHost>
<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
</Proxy>
<VirtualHost *:80>
Include /home/WEBSITEAPP/current/config/apache/dod.conf
ServerName www.WEBSITENAME4.com
ErrorLog logs/WEBSITENAME4_errors_log
CustomLog logs/WEBSITENAME4_log combined
</VirtualHost>
<VirtualHost *:80>
Include /home/WEBSITEAPP/current/config/apache/dl.conf
ServerName www.WEBSITENAME0.com
ErrorLog logs/WEBSITENAME0_errors_log
CustomLog logs/WEBSITENAME0_log combined
</VirtualHost>
<VirtualHost *:80>
Include /home/WEBSITEAPP/current/config/apache/pf.conf
ServerName test.WEBSITENAME1.com
ErrorLog logs/WEBSITENAME1_errors_log
CustomLog logs/WEBSITENAME1_log combined
</VirtualHost>
<VirtualHost *:80>
Include /home/WEBSITEAPP/current/config/apache/dag.conf
ServerName www.WEBSITENAME2.com
ErrorLog logs/WEBSITENAME_errors_log
CustomLog logs/WEBSITENAME_log combined
</VirtualHost>
example of one of the configuration of the virtual hosts -bash-3.00$ cat /home/WEBSITEAPP/current/config/apache/dod.conf
ServerName WEBSITENAME.com
ServerAlias www.WEBSITENAME.com test.WEBSITENAME.com
# Pass other requests to mongrel instance
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
ProxyPreserveHost On
ProxyRequests Off
# Do not allow open proxying, allow only requests starting with a /
<LocationMatch "^[^/]">
Deny from all
</LocationMatch>
DocumentRoot /home/WEBSITEAPP/current/public
<Directory "/home/WEBSITEAPP/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
# Uncomment for rewrite debugging
RewriteLog logs/myapp_rewrite_log
RewriteLogLevel 9
# Check for maintenance file and redirect all requests
# ( this is for use with Capistrano's disable_web task )
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Rewrite index to check for static
# RewriteRule ^/$ /index.html [QSA]
RewriteRule ^/$ /dod/navigation [QSA]
# RewriteRule ^/$ /dl/navigation [L]
# Rewrite to check for Rails cached page
# RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
# RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/(.*)$ balancer://mongrel_cluster/$1 [P,QSA,L]
# RewriteRule "^/(.*)" "http://localhost:8001/$1" [P,QSA,L]
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/css
# ... text/xml application/xml application/xhtml+xml text/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Uncomment for deflate debugging
#DeflateFilterNote Input input_info
#DeflateFilterNote Output output_info
#DeflateFilterNote Ratio ratio_info
#LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
#CustomLog logs/myapp_deflate_log deflate





