Skip to content

Commit 370f528

Browse files
author
António P. P. Almeida
committed
* Moved php-fpm status to a geo block setup.
1 parent 9dd388e commit 370f528

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ This is strictly a **drupal 6** issue.
518518
of IP addresses. In the suggested configuration only from
519519
localhost and non-routable IPs of the 192.168.1.0 network.
520520

521+
The allowed hosts are defined in a geo block in file
522+
`php_fpm_status_allowed_hosts.conf`. You should edit the predefined
523+
IP addresses to suit your setup.
524+
521525
To enable the status and ping pages uncomment the line in the
522526
`example.com.conf` virtual host configuration file.
523527

nginx.conf

+9-5
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ http {
4242
limit_zone arbeit $binary_remote_addr 1m;
4343

4444
## Timeouts.
45-
client_body_timeout 60;
45+
client_body_timeout 60;
4646
client_header_timeout 60;
4747
keepalive_timeout 10 10;
4848
send_timeout 60;
4949

5050
## Reset lingering timed out connections. Deflect DDoS.
5151
reset_timedout_connection on;
52-
52+
5353
## Body size.
5454
client_max_body_size 10m;
5555

@@ -84,7 +84,7 @@ http {
8484
## http://nginx.org/pipermail/nginx/2010-November/023736.html.
8585
ssl_session_cache shared:SSL:10m;
8686
ssl_session_timeout 10m;
87-
87+
8888
## For the filefield_nginx_progress module to work. From the
8989
## README. Reserve 1MB under the name 'uploads' to track uploads.
9090
upload_progress uploads 1m;
@@ -102,9 +102,13 @@ http {
102102
#include reverse_proxy.conf;
103103
#include upstream_phpapache.conf;
104104

105+
## Include the php-fpm status allowed hosts configuration block.
106+
## Uncomment to enable if you're running php-fpm.
107+
#include php_fpm_status_allowed_hosts.conf;
108+
105109
## Include blacklist for bad bot and referer blocking.
106110
include blacklist.conf;
107-
108-
## Include all vhosts.
111+
112+
## Include all vhosts.
109113
include /etc/nginx/sites-enabled/*;
110114
}

php_fpm_status_allowed_hosts.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
### Configuration of php-fpm status and ping pages. Here we define the
3+
### allowed hosts using the Geo Module. http://wiki.nginx.org/HttpGeoModule
4+
5+
geo $dont_show_fpm_status {
6+
default 1;
7+
127.0.0.1 0; # allow on the loopback
8+
192.168.1.0/24 0; # allow on an internal network
9+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- mode: nginx; mode: flyspell-prog; ispell-current-dictionary: american -*-
2+
23
### The configuration for the status pages of php-fpm. As described in
3-
### http://www.php.net/manual/en/install.fpm.configuration.php.
4+
### http://www.php.net/manual/en/install.fpm.configuration.php.
45

56
### php-fpm provides a status and a heartbeat page that is served through the web server.
67
### Here's an example configuration for them.
@@ -10,20 +11,20 @@
1011
## allowed. Non authorized access returns a 404 through the error_page
1112
## directive.
1213
location = /fpm-status {
14+
if ($dont_show_fpm_status) {
15+
return 404;
16+
}
17+
1318
fastcgi_pass phpcgi;
14-
allow 127.0.0.1;
15-
allow 192.168.1.0/24;
16-
error_page 403 =404;
17-
deny all;
1819
}
1920

2021

2122
## The ping page is at /ping and returns the string configured at the php-fpm level.
2223
## Also only local network connections (loopback and LAN) are permitted.
2324
location = /ping {
25+
if ($dont_show_fpm_status) {
26+
return 404;
27+
}
28+
2429
fastcgi_pass phpcgi;
25-
allow 127.0.0.1;
26-
allow 192.168.1.0/24;
27-
error_page 403 =404;
28-
deny all;
2930
}

sites-available/example.com.conf

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ server {
77
## rewriting. See http://wiki.nginx.org/Pitfalls#Server_Name.
88
server_name www.example.com;
99
rewrite ^ $scheme://example.com$request_uri? permanent;
10+
1011
} # server domain rewrite.
1112

1213

@@ -29,7 +30,7 @@ server {
2930
if ($bad_referer) {
3031
return 444;
3132
}
32-
33+
3334
## Filesystem root of the site and index.
3435
root /var/www/sites/example.com;
3536
index index.php;
@@ -80,8 +81,8 @@ server {
8081
### the configuration below.
8182
#################################################################
8283
#include sites-available/drupal_cron_update.conf;
83-
84-
84+
85+
8586
## For upload progress to work. From the README of the
8687
## filefield_nginx_progress module.
8788
location ~ (.*)/x-progress-id:(\w*) {
@@ -94,7 +95,7 @@ server {
9495

9596
## Including the php-fpm status and ping pages config.
9697
## Uncomment to enable if you're running php-fpm.
97-
#include php_fpm_status.conf;
98+
#include php_fpm_status_vhost.conf;
9899

99100
} # HTTP server
100101

@@ -111,7 +112,7 @@ server {
111112

112113
## Keep alive timeout set to a greater value for SSL/TLS.
113114
keepalive_timeout 75 75;
114-
115+
115116
## Disable all methods besides HEAD, GET and POST.
116117
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
117118
return 444;
@@ -121,7 +122,7 @@ server {
121122
## Server certificate and key.
122123
ssl_certificate /etc/ssl/certs/example-cert.pem;
123124
ssl_certificate_key /etc/ssl/private/example.key;
124-
125+
125126
## Strict Transport Security header for enhanced security. See
126127
## http://www.chromium.org/sts. I've set it to 2 hours; set it to
127128
## whichever age you want.
@@ -186,7 +187,7 @@ server {
186187
### the configuration below.
187188
#################################################################
188189
#include sites-available/drupal_cron_update.conf;
189-
190+
190191
## For upload progress to work. From the README of the
191192
## filefield_nginx_progress module.
192193
location ~ (.*)/x-progress-id:(\w*) {

0 commit comments

Comments
 (0)