Configured to support nginx virtual hosts with Drupal using unix sockets.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
conf.d
.gitignore
404.html
README.md
drupal6
drupal7
fastcgi_drupal.conf
fastcgi_private_files.conf
hotlinking_protection.conf
htpasswd.users
ips_allowed.conf
koi-utf
koi-win
mime.types
nginx.conf
scgi_params
uwsgi_params
win-utf

README.md

Configuration for Drupal on nginx virtual hosts using unix sockets

The nginx website has very good documentation and anyone setting up nginx for the first time I suggest you go to the website and actually read the documentation links. It's so easy and so simple, when first learning I wondered if this was almost too easy to read and adapt. I'd recommend to maximize your nginx experience to take a total of half a day or two and read the entirety of the nginx documentation. There isn't a ton and it doesn't take long to learn the directives and how they work common sensically to serve a web page.

Installation

For all the files in your nginx directory, replace any that are included in this package. This configuration has only been tested on CentOS 6, but isn't very operating-system dependent. There is the possibility that your install of nginx came with additional files or folders required for nginx to run properly on your server. Keep those, just replace those files included here.

Using this configuation the default security on Drupal files besides index.php is pretty much lock-down. To access php files other than index.php in your Drupal folder (like update.php, cron.php, etc), add a line with your IP address to ips_allowed.conf. Another option is to use HTTP Basic Authentication provided by nginx. To do so create a htpasswd.users file; in your shell type

htpasswd /path/to/nginx/htpasswd.users <username>

Replace /path/to/nginx with the path to nginx on your server and with the username you'd like to allow to access these files. When prompted, enter the password for this user. Then comment out line 159 in drupal7, and uncomment lines 157 and 158 to switch to using HTTP Authentication.

Credits

I learned nginx don't really see myself going back. Code in this package is adapted, and shamelessly stolen (with some original comments) from:

Features

While this configuration doesn't have everything in perusio's yet it is for a different setup using unix sockets. Adding virtual-host-specific features to the configuration is left as an exercise to the administrator.

  1. php-fpm unix socket support for

  2. Drupal 7 using clean URLs

  3. Multiple virtual hosts in separate small easy to manage files

  4. Basic gzip caching option(s)

  5. One file to save IP addresses of Drupal administrators allowed to visit update.php and install.php

  6. Advanced Aggregation module support Drupal.org:

  7. An HTML5 template for 404 pages with an option to use Drupal instead

  8. HTTP Basic Authentication for folders; like in Apache

  9. Image hotlinking protection

  10. Decent video and audio mp4 streaming config

  11. Support for the Filefield Nginx Progress module for the upload progress bar.

  12. Non-expensive 404s

  13. Advanced Help support.

  14. Security. Among other things, there is no ability to use any pages other than index.php

  15. The Drupal specific headers like X-Drupal-Cache provided by pressflow or the X-Generator header that Drupal 7 has are both hidden.

Conclusion

While this is a work in progress, I wanted to provide my nginx config to get feedback from ninjas so to keep improving. If I had this configuration as a starting point I probably wouldn't have read the documentation on the nginx website. Maybe you won't have to, though I still recommend it. Don't use their Drupal example config, but definitely read the docs.

As of now, this readme needs the most work. Patches, comments, and all feedback is welcome. Commit authorship respected! Mainly I just want to rock a good nginx configuration. +1 open source