Capistrano and XSendFile Configuration

I am trying to configure a Rails server server with Apache 2.2, Passenger 4.0.59 and XSendFile 0.12. The application is deployed through Capistrano.

The deployed application creates (maybe large) PDFs up to #{Rails.root}/tmp and serves this file using send_file .

The problem is that Capistrano uses symbolic links to indicate the current deployed version of the application. XSendFile, on the other hand, shares symbolic links and refuses to serve the file if its actual location is outside the root document, even if it is allowed by XSendFilePath . Apache error.log:

 (20023)The given path was above the root path: xsendfile: unable to find file: /resolved/path/to/file.pdf 

Everything works well when I install PassengerAppRoot and XSendFilePath in the real location of the current version of the application without symbolic links on the way. But this is OK until the next deployment, which requires reconfiguring Apache. Not very helpful.

How do I configure the deployment options of Capistrano and XSendFile so that they work together?

I tried the solutions with ln -nFs described in Capistrano and X- Sendfile and mod_xsendfile with symbolic links but nobody works.

0
ruby-on-rails apache passenger capistrano x-sendfile
source share
1 answer

I finally managed to get it to work. Some tips for those who have problems with XSendFile

  • I installed XSendFilePath user $HOME , there are no symbolic links to $HOME , so it works. I can accept this in terms of functionality and security, but this is obviously a workaround.
  • Remember that XSendFilePath sensitive to paths containing multiple slashes /like//this . I use apache macros and, concatenating the XSendFilePath parameter from several macro parameters, I add some obsolete slashes. This made XSendFile refuse to send files.

Good luck

0
source share

All Articles