Mod_xsendfile with symbolic links

I am having a problem using xsendfile with my Rails 3 application.

I use capistrano to manage deployments and in each version, there is a symbolic link to the shared / assets directory (for example, / var / www / site / releases / 1234 / assets => / var / www / site / shared / assets). The problem is that XSendFile does not seem to follow symbolic links. In my apache logs, I see the following error:

The given path was above the root path: xsendfile: unable to find file: /var/www/site/releases/20110406205607/assets/pdfs/2/original/test.pdf 

I have an XSendFilePath configuration as

 XSendFilePath /var/www/site/shared/assets 

If I switch the configuration to:

 XSendFilePath /var/www/site/releases 

Then everything works fine. So I have a few questions:

1) Is there a way to get XSendFilePath to follow a symbolic link?

2) Is there a security risk when configuring XSendFilePath on my release directory? In other words, do I open access to all of these files?

+8
ruby-on-rails symlink capistrano x-sendfile
source share
1 answer

You create a link using the after "deploy:finalize_update" task after "deploy:finalize_update" , like this:

 task :storage_link, :except => { :no_release => true } do run "ln -nFs #{deploy_to}/shared/assets #{latest_release}/assets" end 

This allows XSendFilePath to see the link as /var/www/site/current/assets , which places it inside the root path.

Also, make sure that the user on which your application is running has write access to / var / www / site / shared / assets.

+7
source share

All Articles