Drupal module that provides Nginx X-Sendfile (X-Accel-Redirect) support for fast private file transfer

Events happening in the community are now at Drupal community events on www.drupal.org.
perusio's picture

Just pushed it to github. Here's the module for Drupal 6. Up and coming is getting the module hosted on d.o and providing a Drupal 7 version.

Comments

very nice, i using xsend with

spacereactor's picture

very nice, i using xsend with mod to nginx for drupal 6. Looking forward to drupal 7 version.

Now included in every Aegir

omega8cc's picture

Now included in every Aegir Octopus instance: https://github.com/omega8cc/nginx-for-drupal/commit/845dff3f01a858340174...

Thanks!

Whenever there is a display

spacereactor's picture

Whenever there is a display from private folder, my error_log will add that the file not found but it still display the image or file. End up my error_log become very big. I have to add crit to error_log in my site.conf (error_log /var/log/nginx/example.com_error.log crit;
) so it doesn't capture those missing items into the error_log. Is is normal?

Right on

perusio's picture

I hadn't given it any consideration up until now. This is how it should be.

  1. There's no file in system/files subdirectory. That's just a Drupal menu entry that returns a page callback that serves the file through PHP.
    With the X-Accel-Redirect usage we're getting around this and instead serve the file directly.

  2. To get rid of the "spurious" 404s you can do:

location ~* /system/files/ {
    error_page 404 = @drupal;
    log_not_found off; # don't log missing files although that's the way it's supposed to be
}

I'm updating the documentation and my nginx config on gihtub. Nice call.

Thanks

Internet Explorer will refuse

spacereactor's picture

Internet Explorer will refuse to load more than 31 linked stylesheets, so how do you outcome this problem since i can't compress the css into single css in private setting.

After many days of searching, I try to http://drupal.org/project/ie_css_optimizer but that require to hack the drupal core in order to work, http://drupal.org/node/572516 #72 provide a custom module that work with apache that doesn't require to hack the drupal core but i can't get it to work on nginx setting. Any suggestion?

Advagg

mikeytown2's picture

I got a module that allows you to use aggregation & a private file system.
http://drupal.org/project/advagg
Check it out, it rocks!

I fail to see what's Apache specific in the module

perusio's picture

that you indicate (issue comment #72) of http://drupal.org/node/572516. It doesn't seem to rely on any Apache specific thing. It's pure drupal.

As for the mentioned constraining of direct dowloads, it's already considered through the usage of internal in the real file location.

Go ahead a try the module in that comment.

not sure where is my mistake,

spacereactor's picture

not sure where is my mistake, if i set the File system path to sites/default/files it work, but if i set it to sites/default/private it doesn't. And when i test it on apache, it doesn't matter if it to sites/default/files or sites/default/private both will work.

i think i just to change all

spacereactor's picture

i think i just to change all from private folder to files folder should solve the problem. Thank you for your time.

A quick summary for others, under private file setting, IE browser only load first 31 css.
install
http://drupal.org/project/ie_css_optimizer
http://drupal.org/node/572516 #72.
Set File system path to sites/default/files or sites/mysite/files and Nginx X-Sendfile (X-Accel-Redirect) should work nicely, now set settings/performance -> Optimize CSS files ->Full optimization

feel like hitting a brick

spacereactor's picture

feel like hitting a brick wall. Now i having another problem, http://domain.com/system/files/photo/general/image.jpg can't be seem even using user1 account but imagecache file is viewable.

I thought any /system/files/ require to check drupal permission right, if the user account given the permission he/she can view the file.

you can find my nginx conf at http://drupal.org/node/1116618 #2

Hmm: I wonder

perusio's picture

what's the issue. Imagecache acesses the files directly, hence there's no permissions involved. The issue is with the users: only authenthicated users can see the images if the filesystem is private.

I'm betting on your filesystem. Some sort of permissions issue.

i using user1 to access and

spacereactor's picture

i using user1 to access and add a role that can access all and it still block. I think it maybe that I did my setup at testing site on test domain name and port the database to actual website, they both on the same server but using different domain and drupal site, so they both independent. The test site work fine but when i port the test site database from to actual site, my actual site doesn't work.

If that is the case, how do i fix it?

P.S what is the filesystem link do you normally enter?
Is it sites/"domainname"/files/private or sites/"domainname"/private or sites/"domainname"/files

According to Perusio Setting

spacereactor's picture

According to Perusio
Setting to private means that the files will be stored in the private directory of your Drupal install. If installed under /var/www/drupal-site/ the private files will be under /var/www/drupal-site/protected. Hence this directory must be writable by the web server.

My mistake is setting the path to site/default/private, when i export the working database to another drupal site the image and file doesn't work. I have to set the file system path to "private/default" if you using just 1 site, if you are sharing multi drupal site, than the path according to the domainname example "private/domainname"

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: