Skip to content

Commit 8e67e8e

Browse files
author
Luis Elizondo
committed
Reorganize configuration files
1 parent 4d51d42 commit 8e67e8e

24 files changed

+2412
-56
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

Dockerfile

+33-26
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ ENV LC_ALL en_US.UTF-8
1111
# Update system
1212
RUN apt-get update && apt-get dist-upgrade -y
1313

14-
# Basic packages
15-
RUN apt-get -y install php5-fpm php5-mysql php-apc php5-imagick php5-imap php5-mcrypt php5-curl php5-cli php5-gd php5-pgsql php5-sqlite php5-common php-pear curl php5-json php5-redis php5-memcache
16-
RUN apt-get -y install nginx-extras
17-
RUN apt-get -y install git curl supervisor
18-
14+
# Prevent restarts when installing
1915
RUN echo '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d
2016

17+
# Basic packages
18+
RUN apt-get -y install php5-fpm php5-mysql php-apc php5-imagick php5-imap php5-mcrypt php5-curl php5-cli php5-gd php5-pgsql php5-sqlite php5-common php-pear curl php5-json php5-redis php5-memcache
19+
RUN apt-get -y install nginx-extras git curl supervisor
20+
2121
RUN php5enmod mcrypt
2222

2323
RUN /usr/bin/curl -sS https://getcomposer.org/installer | /usr/bin/php
@@ -29,12 +29,7 @@ RUN /usr/local/bin/composer self-update
2929
RUN /usr/local/bin/composer global require drush/drush:6.*
3030
RUN ln -s /.composer/vendor/drush/drush/drush /usr/local/bin/drush
3131

32-
# PHP
33-
RUN sed -i 's/memory_limit = .*/memory_limit = 196M/' /etc/php5/fpm/php.ini
34-
RUN sed -i 's/cgi.fix_pathinfo = .*/cgi.fix_pathinfo = 0/' /etc/php5/fpm/php.ini
35-
RUN sed -i 's/upload_max_filesize = .*/upload_max_filesize = 500M/' /etc/php5/fpm/php.ini
36-
RUN sed -i 's/post_max_size = .*/post_max_size = 500M/' /etc/php5/fpm/php.ini
37-
32+
# Prepare directory
3833
RUN mkdir /var/www
3934
RUN usermod -u 1000 www-data
4035
RUN usermod -a -G users www-data
@@ -50,19 +45,31 @@ CMD ["/usr/bin/supervisord", "-n"]
5045
ADD ./startup.sh /opt/startup.sh
5146
RUN chmod +x /opt/startup.sh
5247

53-
# Add configuration files
54-
#ADD ./config/realip.conf /etc/nginx/conf.d/realip.conf
55-
ADD ./config/supervisord-nginx.conf /etc/supervisor/conf.d/supervisord-nginx.conf
5648
RUN mkdir -p /var/cache/nginx/microcache
57-
ADD ./config/nginx.conf /etc/nginx/nginx.conf
58-
ADD ./config/mime.types /etc/nginx/mime.types
59-
ADD ./config/fastcgi.conf /etc/nginx/fastcgi.conf
60-
ADD ./config/blacklist.conf /etc/nginx/blacklist.conf
61-
ADD ./config/fastcgi_microcache_zone.conf /etc/nginx/fastcgi_microcache_zone.conf
62-
ADD ./config/drupal.conf /etc/nginx/drupal.conf
63-
ADD ./config/fastcgi_drupal.conf /etc/nginx/fastcgi_drupal.conf
64-
ADD ./config/map_cache.conf /etc/nginx/map_cache.conf
65-
ADD ./config/microcache_fcgi_auth.conf /etc/nginx/microcache_fcgi_auth.conf
66-
ADD ./config/fastcgi_no_args_drupal.conf /etc/nginx/fastcgi_no_args_drupal.conf
67-
ADD ./config/drupal_upload_progress.conf /etc/nginx/drupal_upload_progress.conf
68-
ADD ./config/default /etc/nginx/sites-enabled/default
49+
50+
### Add configuration files
51+
# Supervisor
52+
ADD ./config/supervisor/supervisord-nginx.conf /etc/supervisor/conf.d/supervisord-nginx.conf
53+
54+
# PHP
55+
ADD ./config/php/www.conf /etc/php5/fpm/pool.d/www.conf
56+
ADD ./config/php/php.ini /etc/php5/fpm/php.ini
57+
58+
# Nginx
59+
ADD ./config/nginx/blacklist.conf /etc/nginx/blacklist.conf
60+
ADD ./config/nginx/drupal.conf /etc/nginx/drupal.conf
61+
ADD ./config/nginx/drupal_upload_progress.conf /etc/nginx/drupal_upload_progress.conf
62+
ADD ./config/nginx/fastcgi.conf /etc/nginx/fastcgi.conf
63+
ADD ./config/nginx/fastcgi_drupal.conf /etc/nginx/fastcgi_drupal.conf
64+
ADD ./config/nginx/fastcgi_microcache_zone.conf /etc/nginx/fastcgi_microcache_zone.conf
65+
ADD ./config/nginx/fastcgi_no_args_drupal.conf /etc/nginx/fastcgi_no_args_drupal.conf
66+
ADD ./config/nginx/map_cache.conf /etc/nginx/map_cache.conf
67+
ADD ./config/nginx/microcache_fcgi_auth.conf /etc/nginx/microcache_fcgi_auth.conf
68+
ADD ./config/nginx/mime.types /etc/nginx/mime.types
69+
ADD ./config/nginx/nginx.conf /etc/nginx/nginx.conf
70+
ADD ./config/nginx/upstream_phpcgi_unix.conf /etc/nginx/upstream_phpcgi_unix.conf
71+
ADD ./config/nginx/map_block_http_methods.conf /etc/nginx/map_block_http_methods.conf
72+
ADD ./config/nginx/map_https_fcgi.conf /etc/nginx/map_https_fcgi.conf
73+
ADD ./config/nginx/nginx_status_allowed_hosts.conf /etc/nginx/nginx_status_allowed_hosts.conf
74+
ADD ./config/nginx/cron_allowed_hosts.conf /etc/nginx/cron_allowed_hosts.conf
75+
ADD ./config/nginx/default /etc/nginx/sites-enabled/default

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ CURRENT_DIRECTORY := $(shell pwd)
33
build:
44
@docker build --tag=iiiepe/nginx-drupal $(CURRENT_DIRECTORY)
55

6+
build-no-cache:
7+
@docker build --no-cache --tag=iiiepe/nginx-drupal $(CURRENT_DIRECTORY)
8+
69
.PHONY: build
710

File renamed without changes.

config/nginx/cron_allowed_hosts.conf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- mode: nginx; mode:autopair; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
### Configuration file for specifying which hosts can invoke Drupal's
3+
### cron. This only applies if you're not using drush to run cron.
4+
5+
geo $not_allowed_cron {
6+
default 1;
7+
## Add your set of hosts.
8+
127.0.0.1 0; # allow the localhost
9+
192.168.1.0/24 0; # allow on an internal network
10+
}
File renamed without changes.

config/drupal.conf renamed to config/nginx/drupal.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,21 @@ location / {
9696

9797
## Run the update from the web interface with Drupal 7.
9898
location = /authorize.php {
99-
fastcgi_pass unix:/var/run/php5-fpm.sock;
99+
fastcgi_pass phpcgi;
100100
}
101101

102102
location = /update.php {
103103
#auth_basic "Restricted Access"; # auth realm
104104
#auth_basic_user_file .htpasswd-users; # htpasswd file
105-
fastcgi_pass unix:/var/run/php5-fpm.sock;
105+
fastcgi_pass phpcgi;
106106
}
107107

108108
## Restrict access to the strictly necessary PHP files. Reducing the
109109
## scope for exploits. Handling of PHP code and the Drupal event loop.
110110
location @drupal {
111111
## Include the FastCGI config.
112112
include fastcgi_drupal.conf;
113-
fastcgi_pass unix:/var/run/php5-fpm.sock;
113+
fastcgi_pass phpcgi;
114114

115115
## FCGI microcache for authenticated users also.
116116
include microcache_fcgi_auth.conf;
@@ -125,7 +125,7 @@ location @drupal-no-args {
125125
## Include the specific FastCGI configuration. This is for a
126126
## FCGI backend like php-cgi or php-fpm.
127127
include fastcgi_no_args_drupal.conf;
128-
fastcgi_pass unix:/var/run/php5-fpm.sock;
128+
fastcgi_pass phpcgi;
129129

130130
## FCGI microcache for authenticated users also.
131131
include microcache_fcgi_auth.conf;
File renamed without changes.
File renamed without changes.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
3+
### This file contains a map directive that is used to block the
4+
### invocation of HTTP methods. Out of the box it allows for HEAD, GET and POST.
5+
6+
map $request_method $not_allowed_method {
7+
default 1;
8+
GET 0;
9+
HEAD 0;
10+
POST 0;
11+
}
File renamed without changes.

config/nginx/map_https_fcgi.conf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# -*- mode: conf; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
### Implement the $https_if_not_empty variable for Nginx versions below 1.1.11.
3+
4+
map $scheme $https {
5+
default '';
6+
https on;
7+
}
File renamed without changes.

config/nginx.conf renamed to config/nginx/nginx.conf

+56-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# https://github.com/perusio/drupal-with-nginx
2-
1+
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
32
user www-data;
43

5-
# Main error log
4+
## If you're using an Nginx version below 1.3.8 or 1.2. then uncomment
5+
## the line below and set it to the number of cores of the
6+
## server. Otherwise nginx will determine it automatically.
7+
#worker_processes 4;
8+
69
error_log /var/log/supervisor/nginx.log;
710
pid /var/run/nginx.pid;
11+
812
worker_rlimit_nofile 8192;
913

1014
events {
@@ -19,7 +23,7 @@ http {
1923
default_type application/octet-stream;
2024

2125
## FastCGI.
22-
include /etc/nginx/fastcgi.conf;
26+
include fastcgi.conf;
2327

2428
## Default log and error files.
2529
access_log /var/log/supervisor/nginx-access.log;
@@ -43,6 +47,13 @@ http {
4347
## ** one if not using nginx version >= 1.1.8.
4448
limit_conn_zone $binary_remote_addr zone=arbeit:10m;
4549

50+
## Define a zone for limiting the number of simultaneous
51+
## connections nginx accepts. 1m means 32000 simultaneous
52+
## sessions. We need to define for each server the limit_conn
53+
## value refering to this or other zones.
54+
## ** Use this directive for nginx versions below 1.1.8. Uncomment the line below.
55+
#limit_zone arbeit $binary_remote_addr 10m;
56+
4657
## Timeouts.
4758
client_body_timeout 60;
4859
client_header_timeout 60;
@@ -53,7 +64,7 @@ http {
5364
reset_timedout_connection on;
5465

5566
## Body size.
56-
client_max_body_size 500m;
67+
client_max_body_size 10m;
5768

5869
## TCP options.
5970
tcp_nodelay on;
@@ -107,7 +118,7 @@ http {
107118
ssl_ecdh_curve secp521r1;
108119

109120
## Enable OCSP stapling. A better way to revocate server certificates.
110-
ssl_stapling on;
121+
#ssl_stapling on;
111122
## Fill in with your own resolver.
112123
resolver 8.8.8.8;
113124

@@ -127,7 +138,7 @@ http {
127138
## See http://wiki.nginx.org/HttpCoreModule#variables_hash_bucket_size
128139
## The line variables_hash_bucket_size was added for completeness but not
129140
## changed from default.
130-
#variables_hash_max_size 1024; # default 512
141+
variables_hash_max_size 1024; # default 512
131142
#variables_hash_bucket_size 64; # default is 64
132143

133144
## For the filefield_nginx_progress module to work. From the
@@ -155,25 +166,49 @@ http {
155166
## Block MIME type sniffing on IE.
156167
add_header X-Content-Options nosniff;
157168

169+
## Include the upstream servers for PHP FastCGI handling config.
170+
## This one uses the FCGI process listening on TCP sockets.
171+
#include upstream_phpcgi_tcp.conf;
172+
173+
## Include the upstream servers for PHP FastCGI handling
174+
## configuration. This setup uses UNIX sockets for talking with the
175+
## upstream.
176+
include upstream_phpcgi_unix.conf;
177+
178+
## Include the map to block HTTP methods.
179+
include map_block_http_methods.conf;
180+
181+
## If using Nginx version >= 1.1.11 then there's a $https variable
182+
## that has the value 'on' if the used scheme is https and '' if not.
183+
## See: http://trac.nginx.org/nginx/changeset/4380/nginx
184+
## http://trac.nginx.org/nginx/changeset/4333/nginx and
185+
## http://trac.nginx.org/nginx/changeset/4334/nginx. If using a
186+
## previous version then uncomment out the line below.
187+
#include map_https_fcgi.conf;
188+
158189
# Support the X-Forwarded-Proto header for fastcgi.
159190
map $http_x_forwarded_proto $fastcgi_https {
160191
default $https;
161192
http '';
162193
https on;
163194
}
164195

165-
##########################################################
166196
## Include the upstream servers for Apache handling the PHP
167197
## processes. In this case Nginx functions as a reverse proxy.
168-
proxy_set_header X-Real-IP $remote_addr;
169-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
170-
proxy_set_header Host $http_host;
171-
## Hide the X-Drupal-Cache header provided by Pressflow.
172-
proxy_hide_header 'X-Drupal-Cache';
173-
## Hide the Drupal 7 header X-Generator.
174-
proxy_hide_header 'X-Generator';
175-
proxy_hide_header 'X-Powered-By';
176-
############################################################
198+
#include reverse_proxy.conf;
199+
#include upstream_phpapache.conf;
200+
201+
## Include the php-fpm status allowed hosts configuration block.
202+
## Uncomment to enable if you're running php-fpm.
203+
#include php_fpm_status_allowed_hosts.conf;
204+
205+
## Include the Nginx stub status allowed hosts configuration block.
206+
include nginx_status_allowed_hosts.conf;
207+
208+
## If you want to run cron using Drupal cron.php. i.e., you're not
209+
## using drush then uncomment the line below. Specify in
210+
## cron_allowed_hosts.conf which hosts can invole cron.
211+
include cron_allowed_hosts.conf;
177212

178213
## Include blacklist for bad bot and referer blocking.
179214
include blacklist.conf;
@@ -184,6 +219,10 @@ http {
184219
## Microcache zone definition for FastCGI.
185220
include fastcgi_microcache_zone.conf;
186221

222+
## If you're using Apache for handling PHP then comment the line
223+
## above and uncomment the line below.
224+
#include proxy_microcache_zone.conf
225+
187226
## Include all vhosts.
188227
include /etc/nginx/sites-enabled/*;
189228
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
3+
### Configuration of nginx stub status page. Here we define the
4+
### allowed hosts using the Geo Module. http://wiki.nginx.org/HttpGeoModule
5+
6+
geo $dont_show_nginx_status {
7+
default 1;
8+
127.0.0.1 0; # allow on the loopback
9+
192.168.1.0/24 0; # allow on an internal network
10+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2+
3+
### Upstream configuration for PHP FastCGI.
4+
5+
## Add as many servers as needed:
6+
## Cf. http://wiki.nginx.org/HttpUpstreamModule.
7+
## Note that this configuration assumes by default that keepalive
8+
## upstream connections are supported and that you have a Nginx
9+
## version with the fair load balancer.
10+
11+
## Add as many servers as needed. Cf. http://wiki.nginx.org/HttpUpstreamModule.
12+
upstream phpcgi {
13+
## Use the least connection algorithm for load balancing. This
14+
## algorithm was introduced in versions 1.3.1 and 1.2.2.
15+
least_conn;
16+
17+
server unix:/var/run/php-fpm.sock;
18+
## Create a backend connection cache. Note that this requires
19+
## Nginx version greater or equal to 1.1.4.
20+
## Cf. http://nginx.org/en/CHANGES. Comment out the following
21+
## line if that's not the case.
22+
keepalive 5;
23+
}

0 commit comments

Comments
 (0)