[Mongrel] Using mod_xsendfile and x_send_file with Mongrel

Mike Garey random49k at gmail.com
Mon Dec 17 20:54:04 EST 2007

Can anyone tell me how to get x_send_file working with mongrel 1.1.1
and apache 2.2?  I've installed the mod_xsendfile apache module from
http://tn123.ath.cx/mod_xsendfile/ and it works fine serving content
from a PHP script, but I can't get it to work with my single Mongrel
instance and ProxyPass.

I'm using the following Apache configuration:

<VirtualHost *:80>
   ServerName myserver.com

   <Location />
     XSendFile on
     XSendFileAllowAbove on

   ProxyPass /images !
   ProxyPass /stylesheets !

   #continue with other static files that should be served by apache

   Alias /images /home/user/myserver/public/images
   Alias /stylesheets /home/user/myserver/public/stylesheets

   #continue with aliases for static content

   ProxyPass / http://localhost:8000/
   ProxyPassReverse / http://localhost:8000/
   ProxyPreserveHost on



:throttle: 0
:docroot: public
:debug: false
:port: 8000
:timeout: 60
:daemon: true
:group: adam
:environment: development
:pid_file: log/mongrel.pid
:cwd: /usr/home/user/myserver
:user: user
:group: user
:log_file: log/mongrel.log

when I use x_send_file with the following in one of my rails controllers:

 x_send_file(@order.file_name, :type => 'text/plain;
charset=us-ascii', :disposition => 'inline')

I get the following error in my apache log:

No such file or directory: xsendfile: cannot open file:

I've tried a few things but I can't seem to get past this error.. I
had a feeling it was because Apache was still trying to pass the
request through the proxy, which was prepending the
http://localhost:8000 to the url, which may have cause dthe error, but
I've tried it with a stylesheet file in my public/stylesheets dir
(which is _not_ proxied - ie will still be served if Mongrel is shut
down) and I still get the same error.

I have a feeling I'm missing something pretty simple, since it seems
that most other people have managed to get this up and running without
too much difficulty.  If anyone has any suggestions, please let me
know!  Thanks,


More information about the Mongrel-users mailing list