Skip to content

Commit c75b6c0

Browse files
committed
* 'D7' of https://github.com/perusio/drupal-with-nginx: * Added woff2 support from PR perusio#255 by @iryston. Added an appropriate mime type for .woff2 * Fix perusio#251 with PR from @kkomelin. * Include PR#11 from @kkomelin about CGI var vuln. Allowed "Well-Known URIs". Cache valid responses for 15s. disable access_log in php_fpm_status_vhost * Disabled SSL v3. * Enable OCSP stapling verification. Update fastcgi_cache_key Issue perusio#212 by colans: Move header-adding to nginx.conf to avoid losing headers. Disabled SSLv3 to fix POODLE vulnerability.
2 parents 21da6b7 + 747fc30 commit c75b6c0

10 files changed

+50
-45
lines changed

Diff for: apps/drupal/drupal.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ location / {
122122
}
123123

124124
## All static files will be served directly.
125-
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
125+
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff2?|svg)$ {
126126

127127
access_log off;
128128
expires 30d;
@@ -349,4 +349,3 @@ location @empty {
349349
location ~* ^.+\.php$ {
350350
return 404;
351351
}
352-

Diff for: apps/drupal/drupal_boost.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ location / {
116116
}
117117

118118
## All static files will be served directly.
119-
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
119+
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff2?|svg)$ {
120120
access_log off;
121121
expires 30d;
122122
## No need to bleed constant updates. Send the all shebang in one
@@ -374,4 +374,3 @@ location = /boost_stats.php {
374374
## comment out the above.
375375
#proxy_pass http://phpapache;
376376
}
377-

Diff for: apps/drupal/drupal_boost_escaped.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ location / {
119119
}
120120

121121
## All static files will be served directly.
122-
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
122+
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff2?|svg)$ {
123123
access_log off;
124124
expires 30d;
125125
## No need to bleed constant updates. Send the all shebang in one
@@ -379,4 +379,3 @@ location = /boost_stats.php {
379379
#proxy_pass http://phpapache;
380380
#proxy_set_header Connection '';
381381
}
382-

Diff for: apps/drupal/drupal_escaped.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ location / {
120120
}
121121

122122
## All static files will be served directly.
123-
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
123+
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff2?|svg)$ {
124124
access_log off;
125125
expires 30d;
126126
## No need to bleed constant updates. Send the all shebang in one
@@ -344,4 +344,3 @@ location @empty {
344344
location ~* ^.+\.php$ {
345345
return 404;
346346
}
347-

Diff for: apps/drupal/microcache_fcgi.conf

+3-22
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ fastcgi_cache microcache;
88
## The cache key.
99
fastcgi_cache_key $scheme$request_method$host$request_uri;
1010

11-
## For 200 and 301 make the cache valid for 1s seconds.
12-
fastcgi_cache_valid 200 301 1s;
11+
## For 200 and 301 make the cache valid for 15 seconds.
12+
fastcgi_cache_valid 200 301 15s;
1313
## For 302 make it valid for 1 minute.
1414
fastcgi_cache_valid 302 1m;
1515
## For 404 make it valid 1 second.
@@ -23,29 +23,10 @@ fastcgi_ignore_headers Cache-Control Expires;
2323
## Bypass the cache.
2424
fastcgi_cache_bypass $no_cache;
2525
fastcgi_no_cache $no_cache;
26-
## Add a cache miss/hit status header.
27-
add_header X-Micro-Cache $upstream_cache_status;
26+
2827
## To avoid any interaction with the cache control headers we expire
2928
## everything on this location immediately.
3029
expires epoch;
31-
## Enable clickjacking protection in modern browsers. Available in
32-
## IE8 also. See
33-
## https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
34-
## This may conflicts with pseudo streaming (at least with Nginx version 1.0.12).
35-
## Uncomment the line below if you're not using media streaming.
36-
## For sites *not* using frames uncomment the line below.
37-
#add_header X-Frame-Options DENY;
38-
## For sites *using* frames uncomment the line below.
39-
#add_header X-Frame-Options SAMEORIGIN;
40-
41-
## Block MIME type sniffing on IE.
42-
add_header X-Content-Options nosniff;
43-
44-
## Strict Transport Security header for enhanced security. See
45-
## http://www.chromium.org/sts. I've set it to 2 hours; set it to
46-
## whichever age you want.
47-
## Uncomment the line below if you're using HTTPS.
48-
#add_header Strict-Transport-Security max-age=7200;
4930

5031
## If you're using a Nginx version greater than 1.1.11 then uncomment
5132
## the line below. See:

Diff for: fastcgi_params

+3
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ fastcgi_param REDIRECT_STATUS 200;
3030
fastcgi_param HTTPS $fastcgi_https if_not_empty;
3131
## For Nginx versions below 1.1.11 uncomment the line below after commenting out the above.
3232
#fastcgi_param HTTPS $fastcgi_https;
33+
34+
## Fix HTTPoxy vulnerability https://httpoxy.org/#mitigate-nginx.
35+
fastcgi_param HTTP_PROXY '';

Diff for: mime.types

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ types {
9797
font/opentype otf;
9898
application/vnd.ms-fontobject eot;
9999
application/font-woff woff;
100+
application/font-woff woff2;
100101

101102
application/octet-stream bin exe dll;
102103
application/octet-stream deb;

Diff for: nginx.conf

+19-13
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ http {
2222
include /etc/nginx/mime.types;
2323
default_type application/octet-stream;
2424

25-
## FastCGI.
26-
include /etc/nginx/fastcgi.conf;
27-
2825
## Default log and error files.
2926
access_log /var/log/nginx/access.log;
3027
error_log /var/log/nginx/error.log;
@@ -40,11 +37,6 @@ http {
4037
## connections nginx accepts. 1m means 32000 simultaneous
4138
## sessions. We need to define for each server the limit_conn
4239
## value refering to this or other zones.
43-
## ** This syntax requires nginx version >=
44-
## ** 1.1.8. Cf. http://nginx.org/en/CHANGES. If using an older
45-
## ** version then use the limit_zone directive below
46-
## ** instead. Comment out this
47-
## ** one if not using nginx version >= 1.1.8.
4840
limit_conn_zone $binary_remote_addr zone=arbeit:10m;
4941

5042
## Define a zone for limiting the number of simultaneous
@@ -109,7 +101,7 @@ http {
109101
ssl_ciphers ECDH+aRSA+AESGCM:ECDH+aRSA+SHA384:ECDH+aRSA+SHA256:ECDH:EDH+CAMELLIA:EDH+aRSA:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA;
110102

111103
## No SSL2 support. Legacy support of SSLv3.
112-
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
104+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
113105

114106
## Pregenerated Diffie-Hellman parameters.
115107
ssl_dhparam /etc/nginx/dh_param.pem;
@@ -119,6 +111,9 @@ http {
119111

120112
## Enable OCSP stapling. A better way to revocate server certificates.
121113
ssl_stapling on;
114+
## Enable verification of OCSP stapling responses by the server.
115+
ssl_stapling_verify on;
116+
122117
## Fill in with your own resolver.
123118
resolver 8.8.8.8;
124119

@@ -163,9 +158,20 @@ http {
163158
## line below.
164159
#add_header X-Frame-Options DENY;
165160

161+
## Enable this if using HTTPS. See sites-available/example.com.conf
162+
## for details.
163+
#add_header Strict-Transport-Security "max-age=7200";
164+
166165
## Block MIME type sniffing on IE.
167166
add_header X-Content-Options nosniff;
168167

168+
## Add a cache miss/hit status header. This can be disabled if not including
169+
## any of the apps/drupal/microcache* files.
170+
add_header X-Micro-Cache $upstream_cache_status;
171+
172+
## FastCGI.
173+
include /etc/nginx/fastcgi.conf;
174+
169175
## Include the upstream servers for PHP FastCGI handling config.
170176
## This one uses the FCGI process listening on TCP sockets.
171177
#include upstream_phpcgi_tcp.conf;
@@ -186,11 +192,11 @@ http {
186192
## previous version then uncomment out the line below.
187193
# include map_https_fcgi.conf;
188194

189-
# Support the X-Forwarded-Proto header for fastcgi.
195+
## Support the X-Forwarded-Proto header for fastcgi.
190196
map $http_x_forwarded_proto $fastcgi_https {
191-
default $https;
192-
http '';
193-
https on;
197+
default $https;
198+
http '';
199+
https on;
194200
}
195201

196202
## Include the upstream servers for Apache handling the PHP

Diff for: php_fpm_status_vhost.conf

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ location = /fpm-status {
1414
return 404;
1515
}
1616
fastcgi_pass www0;
17+
access_log off;
1718
}
1819

1920
## The ping page is at /ping and returns the string configured at the php-fpm level.
@@ -23,6 +24,7 @@ location = /ping {
2324
return 404;
2425
}
2526
fastcgi_pass www0;
27+
access_log off;
2628
}
2729

2830
## This is for the second pool. It assumes that you've configured
@@ -37,6 +39,7 @@ location = /fpm-status-zwei {
3739
return 404;
3840
}
3941
fastcgi_pass www1;
42+
access_log off;
4043
}
4144

4245
## The ping page is at /ping and returns the string configured at the php-fpm level.
@@ -46,6 +49,7 @@ location = /ping-zwei {
4649
return 404;
4750
}
4851
fastcgi_pass www1;
52+
access_log off;
4953
}
5054

5155
## This is for the third pool that acts as backup. It assumes that
@@ -61,6 +65,7 @@ location = /fpm-status-drei {
6165
return 404;
6266
}
6367
fastcgi_pass phpcgi;
68+
access_log off;
6469
}
6570

6671
## The ping page is at /ping and returns the string configured at the php-fpm level.
@@ -70,4 +75,5 @@ location = /ping-drei {
7075
return 404;
7176
}
7277
fastcgi_pass phpcgi;
78+
access_log off;
7379
}

Diff for: sites-available/example.com.conf

+14-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ server {
5656
## Uncomment if you're proxying to Apache for handling PHP.
5757
#proxy_http_version 1.1; # keep alive to the Apache upstream
5858

59+
# Allow "Well-Known URIs" as per RFC 5785.
60+
# Necessary for Let’s Encrypt validation server.
61+
location ~* ^/.well-known/ {
62+
allow all;
63+
}
64+
5965
################################################################
6066
### Generic configuration: for most Drupal 7 sites.
6167
################################################################
@@ -171,10 +177,16 @@ server {
171177
ssl_certificate /etc/ssl/certs/example-cert.pem;
172178
ssl_certificate_key /etc/ssl/private/example.key;
173179

180+
# Disable SSL v3 protocol to fix POODLE bug.
181+
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
182+
174183
## Strict Transport Security header for enhanced security. See
175184
## http://www.chromium.org/sts. I've set it to 2 hours; set it to
176-
## whichever age you want.
177-
add_header Strict-Transport-Security "max-age=7200";
185+
## whichever age you want. However, we can't set this here because adding
186+
## a header will drop all other headers set earlier. See
187+
## http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header
188+
## for details. Instead, uncomment this in nginx.conf.
189+
## add_header Strict-Transport-Security "max-age=7200";
178190

179191
root /var/www/sites/example.com;
180192
index index.php;

0 commit comments

Comments
 (0)