[Mongrel] problem with mongrel/apache2.2.3 and subdomain setup

Rob Sanheim rsanheim at gmail.com
Tue Jan 2 13:19:25 EST 2007

Hi all

I got a vps setup amazingly fast using the deprec recipes on Ubuntu
edgy, but now I'm having a minor issue where my site loads for the
main domain when I only want it accessible from the subdomain.   This
is a pretty typical setup, apache 2.2.3 -> mongrel_proxy_balancer ->
mongrel cluster.  I'm sure I'm missing something obvious in the

I have the conf files pasted below.  Should I just be able to set the
ServerName like I did in myapp.conf for this to work?  Do I need to do
something else in the stock apache config?

Here's the relevant config files:

cwd: /var/www/apps/myapp/current
port: "8000"
environment: production
pid_file: log/mongrel.pid
servers: 2

<VirtualHost *:80>
  ServerName myapp.domain.com

  DocumentRoot /var/www/apps/myapp/current/public

  <Directory /var/www/apps/myapp/current/public>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

  # Configure mongrel_cluster
  <Proxy balancer://myapp_cluster>

  RewriteEngine On

  # Prevent access to .svn directories
  RewriteRule ^(.*/)?\.svn/ - [F,L]
  ErrorDocument 403 "Access Forbidden"

  # Check for maintenance file and redirect all requests
  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]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster
  RewriteRule ^/(.*)$ balancer://myapp%{REQUEST_URI} [P,QSA,L]

  # Deflate
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  ErrorLog logs/myapp.domain.com-error_log
  CustomLog logs/myapp.domain.com-access_log combined
the apache httpd.conf is pretty stock, but here's the part that I
_thought_ would allow me to serve from the main domain just using

ServerName domain.com
DocumentRoot "/usr/local/apache2/htdocs"
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
<Directory "/usr/local/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all


More information about the Mongrel-users mailing list