Over a million developers have joined DZone.

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:

ProxyRequests Off

    Order deny,allow
    Deny from all
    Allow from all

#ProxyPass /
#ProxyPassReverse /
#ProxyPreserveHost On

# End of proxy directives.

Listen 8080

    SetHandler balancer-manager
    Deny from all
    Allow from localhost


Include /home/WEBSITEAPP/current/config/apache/dod.conf

ServerName www.WEBSITENAME4.com

    ErrorLog logs/WEBSITENAME4_errors_log
    CustomLog logs/WEBSITENAME4_log combined

Include /home/WEBSITEAPP/current/config/apache/dl.conf

ServerName www.WEBSITENAME0.com

    ErrorLog logs/WEBSITENAME0_errors_log
    CustomLog logs/WEBSITENAME0_log combined

Include /home/WEBSITEAPP/current/config/apache/pf.conf

ServerName test.WEBSITENAME1.com

    ErrorLog logs/WEBSITENAME1_errors_log
    CustomLog logs/WEBSITENAME1_log combined

Include /home/WEBSITEAPP/current/config/apache/dag.conf

ServerName www.WEBSITENAME2.com

    ErrorLog logs/WEBSITENAME_errors_log
    CustomLog logs/WEBSITENAME_log combined

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 /
ProxyPassReverse /
ProxyPreserveHost On
ProxyRequests Off

# Do not allow open proxying, allow only requests starting with a /

        Deny from all

DocumentRoot /home/WEBSITEAPP/current/public

    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

  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
#  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


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}