GitHub configuration files


I am trying to put together a set of configuration files, generalized
for different web applications (for the moment just Drupal and
WordPress) and with added security. All of them will be modular so that
they can be interchanged, and also I tried to listen to many advices on
this forum, like the use of try_files instead of if, etc. And of course
this needs to be very simple and general so any custom modifications
will be excluded, so that the files can be used on any system and
application. Also, they are made just for NginX and PHP-FPM (or

This is available at and I am open to any
suggestions that you may have.

I am doing this because for the moment finding a good configuration
example is very difficult and involves a lot of searching and
trial&error. Most of them are intended for very specific applications
and must be heavily customized to get them working. You are welcomed to
add any comment you might have.

Posted at Nginx Forum:

I had thought of posting some recipes up at one point as well.

all other requests go to Wordpress

    if (!-e $request_filename) {
      rewrite ^/(.*)$ /index.php?q=$1 last;
      rewrite /(.*)/$ /index.php?q=$1 last;

I don’t think you need that; probably simpler to do try_files there.

I haven’t used wp supercache; I would make two configs, one for
wordpress and one for wordpress with wp supercache. Because my default
wordpress and drupal configs are basically just try_files lines.

Drupal 6 doesn’t support try_files, still needs the if (-e) check.
Drupal 7 works.
Drupal also has a lot of stuff in the document root to set to
“internal” sadly. So I have a location block to handle that.

At the moment, this is my working Drupal 6 config:

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;

location ~*
location ~ /sites/all/scripts/.* { internal; }
location ~ /sites/all/modules/apachesolr/solrbase/.* { internal; }

for wordpress:

all you need is:
try_files $uri $uri/ /index.php?page=$request_uri;


always start out simple, and build from there. :slight_smile:

Thank you for the reply, I will make the necessary changes as soon as
possible. This is exactly why I started this project. Nobody tells you
this stuff, and the configuration files are scattered all over the
internet. And this leads to misconfiguration of nginx and thus to
unsatisfied users. NginX is a great program with great potential and
should be used accordingly.

Posted at Nginx Forum:

drupal on nginx is pretty much covered in these two conf

GitHub - omega8cc/boa: Barracuda Octopus Aegir 4.2.0-stable Grace updated the repo so
the actual nginx.conf for drupal is burried in a old commit
Aegir with Nginx for Dummies Edition · omega8cc/boa@9e0a964 · GitHub

Also, read Nginx | Drupal Groups

I respect the work of the people you mentioned, and most of the
configuration I gathered is from both of these sources, but I don’t want
to limit this to only drupal, or worpdress but also other applications.
Unlike YHager’s repo I would like to update this with all possible
security rules and maybe better organize it. On the other hand Grace’s
configuration is extremely bloated. I don’t really need or afford a
system with aegir, varnish etc.
With advices from you I would like to do this very modular, so that when
someone needs a certain configuration or rules for just a specific
module, it will be available. That’s why I posted this here, to get
feedback. I still have a long way, but it will be soon a good reference
point for a simple nginx machine.

Posted at Nginx Forum: