Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use your nginx-drupal conf on github and follow your thread on g.d.o and nginx mailing list. Thank you for doing this module. I am planning to update most of my sites to d7 by the mid of this year. Will a d7 version of this module come out by then?
Comments
Comment #1
spacereactor CreditAttribution: spacereactor commentedsubscribing
Comment #2
perusio CreditAttribution: perusio commentedThanks for your interest in the module. I hope to have more time for getting the module up to speed on D7 later in the month. Right now I'm commited heavily to a lot of stuff, namely DrupalCamp Lisbon 2011.
I'm planning to work on other Nginx integration modules, addressing caching and security issues.
Comment #3
mike503 CreditAttribution: mike503 commentedSo nice to see an official module, I had hacked up xsend myself for this at one point.
I think D7 will add complexity since the file system stuff has been totally rewritten using the stream style paths.
+1 subscribing too
Comment #4
obrienmd CreditAttribution: obrienmd commentedReally looking forward to a D7 port!
Comment #5
mattman CreditAttribution: mattman commentedHey folks, No need to wait for a D7 port. I did an initial pass today!
Perusio, you'll find that I cloned your d.o. repo and pushed it up to my github account. The 7.x port is within a 7.x-1.x branch. Here's the link.
https://github.com/petrowsky/nginx_accel_redirect/tree/7.x-1.x
If you find the port to be good enough, you can merge the branch or you can make me a co-maintainer. I have d.o. git access and I'll be using the module in conjunction with one of my other modules on omega's boxes.
Enjoy!
Comment #6
perusio CreditAttribution: perusio commentedHello Matt,
Thanks for starting this much belated 7.x branch. I just pushed a new release of the 6.x branch that checks if the private files dir is protected and suggests the relevant Nginx configurations stanzas.
I'm going to look into it now. I'll be back :)
Comment #7
spacereactor CreditAttribution: spacereactor commented#5 i download your 7.x-1.x change the nginx_accel_redirect.info
version = 6.x-1.0
core = 6.x
to
version = 7.x-1.0
core = 7.x
There is my testing for drupal 7 and nginx_accel_redirect.
I set my Private file system path is outside of my website root
my website root is /var/www/mydomain.com/public_html
and my Private file system path is /var/www/mydomain.com/private/default
I upload the some image as private upload. Using Files transfered by PHP work but if switch to Files transferred by Nginx using X-Accel-Redirect. Flash my caches. Those private image doesn't display. If i switch back to Files transfered by PHP, image display again. I did not try to move my Private file system path within the website root
cause i intend to set my Private file system path outside the website root.
These are other modules i install with fresh drupal 7.2
- OG
- Ctools
- Views
- Entity api
- Transliteration
Comment #8
spacereactor CreditAttribution: spacereactor commentedI finally get it work with #5 on drupal 7.2 and nginx 1.0.4
Because my private path is outside the webroot so i have change some part to get it to work. I think if your private path is within your drupal it should work. But for like me this is what is do. 3 things, edit nginx_accel_redirect.info so it can install into drupal 7, edit nginx_accel_redirect.module to point to "protected" folder, edit nginx domainname setting
==========================================
Edit nginx_accel_redirect.info
version = 6.x-1.0
core = 6.x
to
version = 7.x-1.0
core = 7.x
Edit nginx_accel_redirect.module
drupal_send_headers();
// Setting the X-Accel-Redirect header for Nginx.
header('X-Accel-Redirect: ' . base_path() . variable_get('file_private_path', ''). '/' . file_uri_target($uri));
exit();
}
to
drupal_send_headers();
// Setting the X-Accel-Redirect header for Nginx.
header('X-Accel-Redirect: /protected/'. '/' . file_uri_target($uri));
exit();
}
The last thing to do is edit your mydomain.com.conf
location ^~ /protected/ {
internal;
alias /var/www/mydomain.com/private/;
}
==========================================
My private path is /var/www/mydomain/private/ so change according to where you set your private path in drupal setting
All credit go to brianmercer, i look at http://groups.drupal.org/node/36892 for tips.
Comment #9
perusio CreditAttribution: perusio commentedThere's no need to hack anything. The module works with any path that is writable by the web server.
I created the 7.x-1.x-dev tag. Later today I'll update the module to bring it up to speed with the 6.x-1.x branch, namely verifying that the private files dir is protected.
Comment #10
perusio CreditAttribution: perusio commentedHello again Matt,
I've just commited the 7.x-1.x-dev version. I've given you commit access to the project. Thanks for your work on the D7 port and welcome aboard.
Comment #11
spacereactor CreditAttribution: spacereactor commentedi use the 7.x-1.x-dev and i can't access to private files and images.
My website root is point at => /var/www/mydomain.com/public_html
My drupal is store at => /var/www/mydomain.com/public_html
My Private file system path is not within the webroot access.
Step taken on drupal.
1.) goto admin/config/media/file-system
- Public file system path => sites/default/files
- Private file system path => /var/www/mydomain.com/private/default
- Default download method => Private local files served by Drupal.
2.) install Nginx Accel Redirect and enable it.
3.) goto admin/config/media/file-system/nginx-accel-redirect
- X-Accel-Redirect: fast private file transfer support for Nginx => Files transferred by Nginx using X-Accel-Redirect
4.) check all files and image, all can't be view and download.
If i goto admin/config/media/file-system/nginx-accel-redirect and change it back to Files transfered by PHP then all files and images work.
Comment #12
lpalgarvio CreditAttribution: lpalgarvio commented+1 ;)
Comment #13
perusio CreditAttribution: perusio commentedIt's a very bad idea to specify full paths in the drupal filesystem settings form. That should be solely a prerrogative of the web server. Drupal shouldn't care about where the files are in the filesystem. Everything should be relative to its root.
Now to your problem. I fail to see any advantage of having the private files dir outside of your drupal root. Like I said in the discussion on the nginx g.d.o group if it's writable by the webserver, then it's accessible. You have always to protect it explicitly.
It's not even security by obscurity. Nevertheless, if you want to use it, do this:
1. Make a symlink from the drupal root to the directory where you want to have the private files.
ln -s ../private/default private
on your drupal root.2. On the settings form at
admin/config/media/file-system
enter justprivate
.3. Add the following to your vhost config:
4. Reload your Nginx config
service nginx reload
.5. Done.
I'm going to add this to the documentation.
Comment #14
spacereactor CreditAttribution: spacereactor commentedI change Private file system path => sites/default/files/private
create new node with upload some file/image to private path. The node is block if access by http://mydomain.com/system/files/upload/project/photo/sample.jpg
But is access the file directly is accessible and downloadable when i access by http://mydomain.com/sites/default/files/private/upload/photo/sample.jpg
I using most or not all of the nginx drupal 7 setting with your https://github.com/perusio/drupal-with-nginx
Comment #15
perusio CreditAttribution: perusio commentedIt's because you must update your nginx config to protect the new location.
This will work with any directory named
private
, no matter where it is located in the filesystem.You can be more specific. In your case:
Depending on the remainder of your Nginx config you might try a literal location like:
Comment #16
perusio CreditAttribution: perusio commentedI just pushed the 7.x-1.0 release. Thanks to everyone that contributed. Specially Matt that got the 7.x ball rolling.
Test it and provide feedback.