Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm following this tutorial to install apache + unicorn but it seems that apache doesn't serve any of the static files. Here's the config I came up with (take a look at Redirect all non-static requests to unicorn in particular):

<VirtualHost *:80>
  ServerAlias *
  DocumentRoot /var/www/unstilted/current/public

  ErrorDocument 503 /system/maintenance.html

  RewriteEngine On

  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{REQUEST_FILENAME} !/system/maintenance.html
  RewriteRule ^.*$    /system/maintenance.html [L]

  # Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
  RewriteCond  %{THE_REQUEST} ^(GET|HEAD)
  RewriteCond  %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI} -f
  RewriteRule  ^(.*)$ /cache/%{HTTP_HOST}$1 [QSA,L]

  # Rewrite to check for Rails cached html page
  RewriteCond  %{THE_REQUEST} ^(GET|HEAD)
  RewriteCond  %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI}.html -f
  RewriteRule  ^(.*)$ /cache/%{HTTP_HOST}$1.html [QSA,L]

  # no www
  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteRule ^(.*)$ http://%1$1 [R=301,L]

  <Proxy balancer://unicornservers>

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

  ProxyPass / balancer://unicornservers/
  ProxyPassReverse / balancer://unicornservers/
  ProxyPreserveHost on

  <Proxy *>
    Order deny,allow
    Allow from all

In my /var/www/unstilted/current/public directory I have robots.txt, but when I go to, the request goes to unicorn, and it's not handled by apache.

What's wrong with my config? And how do I get Apache to serve the static files?


share|improve this question
I'm not sure but does it work when you remove the ProxyPass*-directives? – vstm Oct 2 '11 at 15:58
up vote 2 down vote accepted

Lose the %{DOCUMENT_ROOT} on that condition. %{REQUEST_FILENAME} is the full filesystem (not URL) path to the file, so it should be matchable like this:

RewriteCond %{REQUEST_FILENAME} !-f
share|improve this answer
Thank you Shane. I tried different combinations but I must have gotten confused and didn't try this. – Ramon Tayag Oct 3 '11 at 15:13
This doesn't solve it for me. – Rob May 6 '12 at 22:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.