Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #216

Closed
wants to merge 99 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3efa6aa
* First commit of D7 only branch.
Dec 1, 2012
d163df3
* Removed event notification mechanism. Nginx always selects the best…
Dec 2, 2012
76069c4
* README updated with drupal version specific config information.
Dec 2, 2012
b64e222
* README fixed.
Dec 2, 2012
ee5a946
* Added HTTPS redirect from www to base domain.
Dec 2, 2012
33f190a
* Reinstated drupal installation script include. This was a regression.
Jan 5, 2013
6e14519
* Fixed indentation.
Jan 7, 2013
833329c
Update apps/drupal/drupal.conf
wismoyo Jan 9, 2013
2e46f60
Merge pull request #80 from wismoyo/patch-1
perusio Jan 9, 2013
56bae3d
* Fixed the wrong paths for cache config files. Thx wismoyo.
Jan 9, 2013
238dca5
Fixing https example
VisualFox Jan 15, 2013
3ff86e4
Merge pull request #82 from VisualFox/D7
perusio Jan 16, 2013
a7f423f
* Allowed Lynx on blacklist.conf.
Jan 20, 2013
8a32bf4
Merge branch 'D7' of github.com:perusio/drupal-with-nginx into D7
Jan 20, 2013
7cd2d3b
Hotlinking include
RuZniki Mar 13, 2013
0cf6dac
Merge pull request #89 from RuZniki/patch-1
perusio Mar 13, 2013
77063ea
Added x-forwarded-proto support for https incase of loadbalanced env
smoneyan Mar 22, 2013
59ac2e6
added map_https_forwarded_proto.conf file
smoneyan Mar 22, 2013
343b31b
minor indendation fixed
smoneyan Mar 22, 2013
2f926ea
Merge pull request #92 from smoneyan/D7
perusio Mar 22, 2013
52eeea3
* Fixed the incorrect server names in valid_referers directive. Thx E…
Apr 4, 2013
60fed8c
* Fixed hotlinking protection inclusion.
Apr 4, 2013
9f37161
* IPv6 fixes.
Apr 8, 2013
ae9dcc6
* README updated.
Apr 8, 2013
9bfcef7
* IPv6 default server vhost fixed.
Apr 8, 2013
a6cc19d
* Typo fix.
Apr 8, 2013
463b172
* SPDY support added.
Apr 8, 2013
c021f23
* Fix SPDY listen directive comment.
Apr 8, 2013
75b4b81
* Fixed utf-8 charset.
Apr 8, 2013
5d47cef
* Fixed problem with HTTPS FCGI parameter.
Apr 20, 2013
4812e06
* Updated the escaped setup to reflect new Lua module. Thx trankzen.
Apr 28, 2013
f4a63c9
* New placement of escaped URI config.
Apr 28, 2013
40617ad
* Removed file for escaped URI setting.
Apr 28, 2013
884d3dd
Put $scheme in the cache key.
smerrill Apr 30, 2013
7f0412e
Merge pull request #103 from smerrill/microcache-by-scheme
perusio May 1, 2013
77df58c
* Support for file_force module added. README updated.
May 5, 2013
5ff1d30
* Fixed https scheme for drupal.org links. Thx gasperz.
May 7, 2013
2cda266
Fixed file_force module link on drupal.org
iryston May 9, 2013
a30f4f1
Adult referrer added
iryston May 9, 2013
269a011
Corrected code comments
iryston May 9, 2013
da16902
Deleted extra spaces after lines
iryston May 9, 2013
7b3911c
Extend known MIME types
iryston May 9, 2013
e728586
Some fixes in configuration files:
iryston May 9, 2013
d86ae31
Merge pull request #108 from iryston/D7
perusio May 9, 2013
0f5c7aa
* Indentation fixes.
May 9, 2013
394fa64
* Moved all drupal config specific files an fixed image handling for …
May 12, 2013
b8cdf37
* Fixed STS header for microcache and add X-Content-Options.
May 27, 2013
a9e9787
* Added note about X-Content-Options to README.
May 27, 2013
fda1fca
* Fixed @drupal-no-args setting.
May 27, 2013
2f63bfa
* Added support for robotstxt module.
May 28, 2013
f224668
* Fixed incorrectly placed line for X-Frame-Options comment.
May 28, 2013
97d34e3
* Fixed comments on microcache.
Jun 4, 2013
1490f32
* Added basic auth protection for /admin URIs.
Jun 11, 2013
546c8f9
* README updated for /admin protection with basic auth.
Jun 12, 2013
d011531
Move file fastcgi_no_args_drupal.conf to the right location
deminy Jul 9, 2013
6a4666b
Merge pull request #121 from deminy/D7
perusio Jul 19, 2013
4179863
* Added application/json to be gzipped.
Jul 29, 2013
10468df
* Keepalive fix for proxying to Apache.
Jul 31, 2013
88d05c3
Merge branch 'D7' of github.com:perusio/drupal-with-nginx into D7
Sep 10, 2013
9fb2f57
* php-fpm status fix for two pools.
Sep 10, 2013
966eebc
* Merge pull request for better instructions when cloning repo.
Sep 10, 2013
bfa7c8e
Correct some MIME types according to RFC
iryston Sep 28, 2013
55cad44
Adding configuration for Drupal 7 sites to serve URIs that need to be…
iryston Sep 28, 2013
7d4d8ac
Adding HTTPS 'on' parameter to fastcgi_no_args_drupal.conf
iryston Sep 28, 2013
b1f8e11
Merge pull request #130 from iryston/D7
perusio Oct 16, 2013
a61f368
Update README.md
perusio Nov 19, 2013
24a39ca
* Added cache exception for Ajax calls.
Dec 3, 2013
2e72ca5
* The cache bypassing rules and key for authenticated users setup is
Dec 3, 2013
9e056d5
* Fixed advagg handling.
Dec 8, 2013
c094d3b
* Static file regex improvement.
Dec 9, 2013
40f502b
* Style improvements.
Dec 9, 2013
b4f5d73
* Added web fonts to static files handling.
Dec 14, 2013
a8c990b
* Replaced the fair algorithm for load balancing algorithm by least c…
Dec 15, 2013
0d5d369
* Added PFS setup for SSL hosts.
Dec 15, 2013
e58970b
* Style fix.
Dec 15, 2013
873630e
* Set the number of worker processes automatically.
Dec 16, 2013
361d0f4
Added missing semicolons
yveslaroche Dec 28, 2013
4befd1f
Merge pull request #142 from yveslaroche/D7
perusio Dec 28, 2013
ff9282b
Comment typo correction
iryston Jan 4, 2014
9033ad7
Merge pull request #144 from iryston/D7
perusio Jan 7, 2014
1fbf500
Should say example.net here.
redcrate Jan 27, 2014
54b4059
* Hardened SSL/TLS configuration.
Jan 28, 2014
29a4ea5
* 3O MB for SSL session cache.
Jan 28, 2014
db55f48
Merge pull request #152 from aberhow/patch-2
perusio Jan 28, 2014
2cc47ab
* Added OCSP stapling and better security headers.
Jan 28, 2014
38ba0d9
Merge branch 'D7' of github.com:perusio/drupal-with-nginx into D7
Jan 30, 2014
eb90b2b
Corrected typo that meant 200 and 301 responses were valid for 15 sec…
Feb 9, 2014
f618d34
* Added missing php-fpm pool status upstreams.
Feb 13, 2014
07a50a1
Fixed incorrect name of ssl_dhparam directive.
calipzo Feb 15, 2014
2010e70
* Fixed double ;.
Feb 15, 2014
a1fc3b3
Merge pull request #159 from calipzo/patch-1
perusio Feb 16, 2014
1b55740
Added section pertaining to nginx message [emerg] could not build the…
Feb 26, 2014
05e5131
Merge pull request #161 from troubleshooter/D7
perusio Mar 11, 2014
81aa86d
Merge pull request #157 from shrikeh/bug/fix-fastcgi-microcache-duration
perusio Mar 11, 2014
9a248f5
Fix support of the X-Forwarded-Proto header for fastcgi.
Mar 26, 2014
35ee49f
Merge pull request #166 from Pheromone/D7
perusio Mar 26, 2014
0acb9e5
Update microcache_fcgi.conf
javdl May 8, 2014
692bbc0
Merge pull request #169 from Joostvanderlaan/patch-1
perusio May 8, 2014
852284f
Update README.md
MarioBaron May 31, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 80 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,24 @@
greater security.

This configuration started life as a fork of
[yhager's](github.com/yhager/nginx_drupal) configuration, tempered
by [omega8cc](http://github.com/omega8cc/nginx-for-drupal) and
[Brian Mercer](http://test.brianmercer.com/content/nginx-configuration-drupal)
(dead link) configurations.

I've since then changed it substantially. Tried to remove as best
as I can the traces of bad habits promoted by Apache's
configuration logic. Namely the use of a `.htaccess` and what it
entails in terms or _reverse logic_ on the server
configuration. I've incorporated tidbits and advices gotten,
mostly, from the nginx mailing list and the
[Perusio's](https://github.com/perusio/drupal-with-nginx) configuration.

I've since then changed it somewhat. Mainly by adding or improving support for some additional Drupal modules, as well as, removing Drupal 6 branch which in the wake of Drupal 8 release, I now consider completely obsolete.
I've incorporated tidbits and advices gotten mostly, from the nginx mailing list and the
[nginx Wiki](http://wiki.nginx.org).

## I'm in a hurry just show me how to install it

Jump **immediately** to the [installation](drupal-with-nginx#installation).
Jump **immediately** to the [installation](#installation).
I'll read up on all other stuff **later**.

## Layout

The configuration comes in **two** flavors:
The configuration comes in **two** flavors:

1. Drupal 6.
1. Drupal 6.

2. Drupal 7.
2. Drupal 7.

Furthermore there are **two** options for each configuration:

Expand All @@ -61,7 +54,7 @@ Furthermore there are **two** options for each configuration:
example aliases file `example.aliases.drushrc.php` that comes
under the `examples` directory in the drush distribution.

Example: You create the aliases for example.com and example.org,
Example: You create the aliases for example.com and example.net,
with aliases `@excom` and `@exnet` respectively.

Your crontab should contain something like:
Expand All @@ -81,6 +74,22 @@ Furthermore there are **two** options for each configuration:
script. If using `drush.php` then add `php` in front of the
`/path/to/drush.php`.

## Branching

The configuration has 3 main branches:

1. A [D7](https://github.com/perusio/drupal-with-nginx/tree/D7) branch
if you're running **Drupal 7** sites only on a given machine **use
this branch**.

2. A [D6](https://github.com/perusio/drupal-with-nginx/tree/D6) branch
if you're running **Drupal 6** sites only on a given machine **use
this branch**.

3. A [master](https://github.com/perusio/drupal-with-nginx) branch if
you're running **both Drupal 6 and Drupal 7** sites on a given
machine **use this branch**.

## Escaped URIs

It happens that some sites have URIs that use
Expand All @@ -106,47 +115,36 @@ version.
## Configuration Selection Algorithm

1. I'm **not** using [Boost](http://drupal.org/project/boost):

* On **drupal 7** use the `drupal.conf` config in your vhost
(`server` block): `include apps/drupals/drupal.conf;`.

* On **drupal 7** having to serve URIs that need to be **escaped**,
e.g., that have `+` and/or `?` then use the `drupal_escaped.conf`
config in your vhost (`server` block):
`include apps/drupal/drupal_escaped.conf`.

* On **drupal 6** use the `drupal6.conf` config in your vhost
(`server` block): `include apps/drupals/drupal6.conf;`.

* On **drupal 6** if having to serve URIs that need to be
**escaped**, e.g., that have `+` and/or `?` then use the
`drupal6_escaped.conf` config in your vhost (`server` block):
`include apps/drupal/drupal6_escaped.conf`.

2. I'm using [Boost](http://drupal.org/project/boost) for caching
on my drupal site.

* On **drupal 7** use the `drupal_boost.conf` config in your vhost
(`server` block): `include apps/drupal/drupal_boost.conf;`.

* On **drupal 7** if having to serve URIs that need to be
**escaped**, e.g., that have `+` and/or `?` then use the
`drupal_boost_escaped.conf` config in your vhost (`server` block):
`include apps/drupal/drupal_boost_escaped.conf`.

* On **drupal 6** use the `drupal_boost6.conf` config in your vhost
(`server` block): `include apps/drupal/drupal_boost6.conf;`.

* On **drupal 6** if having to serve URIs that need to be
**escaped**, e.g., that have `+` and/or `?` then use the
`drupal_boost6_escaped.conf` config in your vhost (`server`
block): `include apps/drupal/drupal_boost6_escaped.conf`.

3. I'm **not using drush** for updating and running
cron. Additionally you should also include the
`drupal_cron_update.conf` config in your vhost (`server` block):
`include apps/drupal/drupal_cron_update.conf;`

4. I'm using **drupal 8**. Just use the drupal 7 configuration. The
only thing that changes so far is the location of `install.php`.

Expand Down Expand Up @@ -267,7 +265,9 @@ This is strictly a **drupal 6** issue.
20. [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) support. This
requires a Nginx version greater or equal to **1.3.3**.

21. Support for drupal 8.
21. Support for drupal 8.

22. Support for the [`file_force`](http:/drupal.org/project/file_force) module.

## Secure HTTP aka SSL/TLS support

Expand Down Expand Up @@ -357,10 +357,15 @@ This is strictly a **drupal 6** issue.
then accordingly change its name in drupal_boost.conf.

4. Support for
[X-Frame-Options](https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header)
[`X-Frame-Options`](https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header)
HTTP header to avoid Clickjacking attacks.

5. Support for
[`X-Content-Options`](http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx?Redirected=true)
for avoiding MIME type deviation from the declared
`Content-Type`.

5. Protection of the upload directory. You can try to bypass the
6. Protection of the upload directory. You can try to bypass the
UNIX `file` utility or the PHP `Fileinfo` extension and upload a
fake jpeg:

Expand All @@ -383,23 +388,25 @@ This is strictly a **drupal 6** issue.
it always from within the Nginx config. You cannot access it
directly from outside.

6. Use of [Strict Transport Security](http://www.chromium.org/sts
7. Use of [Strict Transport Security](http://www.chromium.org/sts
"STS at chromium.org") for enhanced security. It forces during
the specified period for the configured domain to be contacted
only over HTTPS. Requires a modern browser to be of use, i.e.,
**Chrome/Chromium**, **Firefox 4** or **Firefox with
NoScript**.

7. DoS prevention with a _low_ number of connections by client
8. DoS prevention with a _low_ number of connections by client
allowed: **32**. This number can be adjusted as you see fit.

8. The Drupal specific headers like `X-Drupal-Cache` provided by
9. The Drupal specific headers like `X-Drupal-Cache` provided by
[pressflow](https://github.com/pressflow/6) or the `X-Generator`
header that Drupal 7 sets are both **hidden**.

9. Limitation of allowed HTTP methods. Out of the box only `GET`,
10. Limitation of allowed HTTP methods. Out of the box only `GET`,
`HEAD` and `POST`are allowed.

11. Protection of the `/admin` URIs with Basic Auth.

## Private file handling

This config assumes that **private** files are stored under a directory
Expand Down Expand Up @@ -539,6 +546,19 @@ This is strictly a **drupal 6** issue.
directive and enumerate the client IPs that are allowed to use the
*extra* methods like `PUT`.

## Protection of the `/admin` URIs using Basic Auth

Just uncomment the line that includes the
`apps/drupal/admin_basic_auth.conf` file. Now whenever you got to a
`/admin` URI the server will prompt you for a username/password
pair. Note that by default this config provides no
username/password values for the `.htpasswd-users` file. This is to
avoid the creeping of laziness and that 80% of the sites that have
the `/admin` URIs protected have the same username/password.

Note that this is much more effective if at least all your logged
in traffic goes over SSL (HTTPS).

## Multisite support

[Drupal multisite](http://drupal.org/documentation/install/multi-site)
Expand Down Expand Up @@ -738,13 +758,29 @@ replace** the indicated address by **your** address.
For Nginx versions greater or equal than 1.3.4 IPv6 and IPv4 sockets
are **separate** by default.

Note also that socket options like `ipv6only=on` can only be specified
**once**. Hence the use of different IPv6 addresses for the server
block that redirects from `www` to the base domain in both HTTP and
HTTPS servers.

## Installation

1. Move the old `/etc/nginx` directory to `/etc/nginx.old`.

2. Clone the git repository from github:

git clone https://github.com/perusio/drupal-with-nginx.git

git clone https://github.com/perusio/drupal-with-nginx.git /etc/nginx

If you want to use only the Drupal specific version configuration
you must do one of the checkouts below:

* For the **D7** branch (running **only** D7 sites on the same server):

git checkout D7

* For the **D6** branch (running **only** D6 sites on the same server):

git checkout D6

3. Edit the `sites-available/example.com.conf` configuration file to
suit your requirements. Namely replacing example.com with **your**
Expand Down Expand Up @@ -834,6 +870,13 @@ are **separate** by default.
for Nginx to serve.


## Troubleshooting

If by any reason you have some kind of error, please get a
[debug log](http://nginx.org/en/docs/debugging_log.html) and paste it
in a [Gist](https://gist.github.com) and **open an issue** on the
github issue queue for the module.

## Acessing the php-fpm status and ping pages

You can get the
Expand Down Expand Up @@ -876,7 +919,7 @@ are **separate** by default.
own. Generally the APT machinery will sort out for you any
dependencies issues that might exist.

## Ad and Aditional modules support
## Ad and Additional modules support

The config is quite tight in the sense that if you have something
that is not contemplated in the **exact** match locations,
Expand Down
12 changes: 12 additions & 0 deletions apps/drupal/admin_basic_auth.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-

## Protect the /admin URIs with a basic auth.
location ^~ /admin {
auth_basic "Restricted access"; #realm
auth_basic_user_file .htpasswd-users;

## Include the specific FastCGI configuration. This is for a
## FCGI backend like php-cgi or php-fpm.
include apps/drupal/fastcgi_drupal.conf;
fastcgi_pass phpcgi;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ geo $not_allowed_cron {
default 1;
## Add your set of hosts.
127.0.0.1 0; # allow the localhost
192.168.1.0/24 0; # (V)LAN hosts allowed
192.168.1.0/24 0; # allow on an internal network
}
Loading