# Xsendfile not working

**URL:** <https://www.ruby-forum.com/t/xsendfile-not-working/111485>\
**Category:** Rails\
**Created:** [August 7, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/xsendfile-not-working/111485 "2007-08-07T21:25:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddavis\_onset](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@ddavis\_onset](https://www.ruby-forum.com/u/ddavis_onset)\
**Post date:** [August 7, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/xsendfile-not-working/111485/1 "2007-08-07T21:25:24Z")

</div>

Hi,

I am running apache web server 2.2.4 in front of mongrel on linux.  
I can’t get x\_send\_file to work.

A couple errors are happening.

1. In apache, I have the configured where mydir is the  
directory containing the files I want to download with XSendfile. When  
I have “XSendFile on” directive within the Directory definition, mongrel  
serves up the download file itself instead of handing it off to apache.

To work around this problem, I temporarily put “XSendFile on” in as a  
global directive- i.e. not within a \<Directory …\> or \<Files …\> tag.  
This I think got me past that error and onto the next which is:

1. A request is going to apache now, but it is not that of the header I  
constructed in my ruby code. It reads  
/[path-to-controller];form\_action?[query-string]

my code:  
x\_send\_file(zip\_file.to\_s, :filename =\> ‘hobolink.zip’)  
OR  
response.headers[‘Content-Type’] = “application/force-download”  
response.headers[‘Content-Disposition’] = “attachment;  
filename=“myfile.zip””  
response.headers[“X-Sendfile”] = “#{path}”  
response.headers[‘Content-Length’] = File.size(zip\_file.to\_s)

For the minimal amount of documentation I can find on implementing this  
feature, I feel like it should be very simple. For some reason, I’m  
having a hard time getting the configuration right.

thanks in advance!  
Danielle
