Skip to content

Commit d6565c1

Browse files
committed
DEVOPS: Clean up in docker server compose and vhost config
1 parent 6a081bc commit d6565c1

File tree

9 files changed

+34
-179
lines changed

9 files changed

+34
-179
lines changed

templates/drupal-7/.docker/vhost.conf

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# @see https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
21
server {
32
listen 80;
43
server_name localhost;
@@ -16,9 +15,7 @@ server {
1615
access_log off;
1716
}
1817

19-
# Very rarely should these ever be accessed outside of your lan
2018
location ~* \.(txt|log)$ {
21-
allow 192.168.0.0/16;
2219
deny all;
2320
}
2421

@@ -30,56 +27,31 @@ server {
3027
return 403;
3128
}
3229

33-
# Block access to scripts in site files directory
3430
location ~ ^/sites/[^/]+/files/.*\.php$ {
3531
deny all;
3632
}
3733

38-
# Allow "Well-Known URIs" as per RFC 5785
39-
location ~* ^/.well-known/ {
40-
allow all;
41-
}
42-
43-
# Block access to "hidden" files and directories whose names begin with a
44-
# period. This includes directories used by version control systems such
45-
# as Subversion or Git to store control files.
4634
location ~ (^|/)\. {
4735
return 403;
4836
}
4937

5038
location / {
51-
# try_files $uri @rewrite; # For Drupal <= 6
52-
try_files $uri /index.php?$query_string; # For Drupal >= 7
39+
try_files $uri /index.php?$query_string;
5340
}
5441

5542
location @rewrite {
5643
rewrite ^/(.*)$ /index.php?q=$1;
5744
}
5845

59-
# Don't allow direct access to PHP files in the vendor directory.
6046
location ~ /vendor/.*\.php$ {
6147
deny all;
6248
return 404;
6349
}
6450

65-
# In Drupal 8, we must also match new paths where the '.php' appears in
66-
# the middle, such as update.php/selection. The rule we use is strict,
67-
# and only allows this pattern with the update.php front controller.
68-
# This allows legacy path aliases in the form of
69-
# blog/index.php/legacy-path to continue to route to Drupal nodes. If
70-
# you do not have any paths like that, then you might prefer to use a
71-
# laxer rule, such as:
72-
# location ~ \.php(/|$) {
73-
# The laxer rule will continue to work if Drupal uses this new URL
74-
# pattern with front controllers other than update.php in a future
75-
# release.
7651
location ~ '\.php$|^/update.php' {
7752
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
78-
# Security note: If you're running a version of PHP older than the
79-
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
80-
# See http://serverfault.com/q/627903/94922 for details.
8153
include fastcgi_params;
82-
# Block httpoxy attacks. See https://httpoxy.org/.
54+
8355
fastcgi_param HTTP_PROXY "";
8456
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8557
fastcgi_param PATH_INFO $fastcgi_path_info;
@@ -88,15 +60,11 @@ server {
8860
fastcgi_pass phpfpm:9000;
8961
}
9062

91-
# Fighting with Styles? This little gem is amazing.
92-
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
93-
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
63+
location ~ ^/sites/.*/files/styles/ {
9464
try_files $uri @rewrite;
9565
}
9666

97-
# Handle private files through Drupal. Private file's path can come
98-
# with a language prefix.
99-
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
67+
location ~ ^(/[a-z\-]+)?/system/files/ {
10068
try_files $uri /index.php?$query_string;
10169
}
10270

templates/drupal-8/.docker/vhost.conf

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# @see https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
21
server {
32
listen 80;
43
server_name localhost;
@@ -16,9 +15,7 @@ server {
1615
access_log off;
1716
}
1817

19-
# Very rarely should these ever be accessed outside of your lan
2018
location ~* \.(txt|log)$ {
21-
allow 192.168.0.0/16;
2219
deny all;
2320
}
2421

@@ -35,11 +32,6 @@ server {
3532
deny all;
3633
}
3734

38-
# Allow "Well-Known URIs" as per RFC 5785
39-
location ~* ^/.well-known/ {
40-
allow all;
41-
}
42-
4335
# Block access to "hidden" files and directories whose names begin with a
4436
# period. This includes directories used by version control systems such
4537
# as Subversion or Git to store control files.
@@ -48,8 +40,7 @@ server {
4840
}
4941

5042
location / {
51-
# try_files $uri @rewrite; # For Drupal <= 6
52-
try_files $uri /index.php?$query_string; # For Drupal >= 7
43+
try_files $uri /index.php?$query_string;
5344
}
5445

5546
location @rewrite {
@@ -62,41 +53,26 @@ server {
6253
return 404;
6354
}
6455

65-
# In Drupal 8, we must also match new paths where the '.php' appears in
66-
# the middle, such as update.php/selection. The rule we use is strict,
67-
# and only allows this pattern with the update.php front controller.
68-
# This allows legacy path aliases in the form of
69-
# blog/index.php/legacy-path to continue to route to Drupal nodes. If
70-
# you do not have any paths like that, then you might prefer to use a
71-
# laxer rule, such as:
72-
# location ~ \.php(/|$) {
73-
# The laxer rule will continue to work if Drupal uses this new URL
74-
# pattern with front controllers other than update.php in a future
75-
# release.
7656
location ~ '\.php$|^/update.php' {
7757
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
78-
# Security note: If you're running a version of PHP older than the
79-
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
80-
# See http://serverfault.com/q/627903/94922 for details.
8158
include fastcgi_params;
82-
# Block httpoxy attacks. See https://httpoxy.org/.
59+
8360
fastcgi_param HTTP_PROXY "";
8461
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8562
fastcgi_param PATH_INFO $fastcgi_path_info;
8663
fastcgi_param QUERY_STRING $query_string;
64+
8765
fastcgi_intercept_errors on;
8866
fastcgi_pass phpfpm:9000;
8967
}
9068

91-
# Fighting with Styles? This little gem is amazing.
92-
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
93-
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
69+
location ~ ^/sites/.*/files/styles/ {
9470
try_files $uri @rewrite;
9571
}
9672

9773
# Handle private files through Drupal. Private file's path can come
9874
# with a language prefix.
99-
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
75+
location ~ ^(/[a-z\-]+)?/system/files/ {
10076
try_files $uri /index.php?$query_string;
10177
}
10278

templates/drupal-8/docker-compose.server.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# itk-version: 1.0.0
1+
# itk-version: 1.0.1
22
version: "3"
33

44
networks:
@@ -22,7 +22,6 @@ services:
2222
- memcached
2323
volumes:
2424
- .:/app:delegated
25-
- drush-cache:/root/.drush
2625

2726
nginx:
2827
image: nginx:stable-alpine
@@ -55,17 +54,3 @@ services:
5554
- app
5655
environment:
5756
- MEMCACHED_CACHE_SIZE=64
58-
59-
drush:
60-
image: itkdev/drush6:latest
61-
networks:
62-
- app
63-
entrypoint:
64-
- drush
65-
volumes:
66-
- drush-cache:/root/.drush
67-
- ./:/app
68-
69-
# Drush cache volume to persist cache between runs.
70-
volumes:
71-
drush-cache:

templates/drupal-9/.docker/vhost.conf

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# @see https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
21
server {
32
listen 80;
43
server_name localhost;
@@ -16,9 +15,7 @@ server {
1615
access_log off;
1716
}
1817

19-
# Very rarely should these ever be accessed outside of your lan
2018
location ~* \.(txt|log)$ {
21-
allow 192.168.0.0/16;
2219
deny all;
2320
}
2421

@@ -35,11 +32,6 @@ server {
3532
deny all;
3633
}
3734

38-
# Allow "Well-Known URIs" as per RFC 5785
39-
location ~* ^/.well-known/ {
40-
allow all;
41-
}
42-
4335
# Block access to "hidden" files and directories whose names begin with a
4436
# period. This includes directories used by version control systems such
4537
# as Subversion or Git to store control files.
@@ -48,8 +40,7 @@ server {
4840
}
4941

5042
location / {
51-
# try_files $uri @rewrite; # For Drupal <= 6
52-
try_files $uri /index.php?$query_string; # For Drupal >= 7
43+
try_files $uri /index.php?$query_string;
5344
}
5445

5546
location @rewrite {
@@ -62,41 +53,26 @@ server {
6253
return 404;
6354
}
6455

65-
# In Drupal 8, we must also match new paths where the '.php' appears in
66-
# the middle, such as update.php/selection. The rule we use is strict,
67-
# and only allows this pattern with the update.php front controller.
68-
# This allows legacy path aliases in the form of
69-
# blog/index.php/legacy-path to continue to route to Drupal nodes. If
70-
# you do not have any paths like that, then you might prefer to use a
71-
# laxer rule, such as:
72-
# location ~ \.php(/|$) {
73-
# The laxer rule will continue to work if Drupal uses this new URL
74-
# pattern with front controllers other than update.php in a future
75-
# release.
7656
location ~ '\.php$|^/update.php' {
7757
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
78-
# Security note: If you're running a version of PHP older than the
79-
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
80-
# See http://serverfault.com/q/627903/94922 for details.
8158
include fastcgi_params;
82-
# Block httpoxy attacks. See https://httpoxy.org/.
59+
8360
fastcgi_param HTTP_PROXY "";
8461
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8562
fastcgi_param PATH_INFO $fastcgi_path_info;
8663
fastcgi_param QUERY_STRING $query_string;
64+
8765
fastcgi_intercept_errors on;
8866
fastcgi_pass phpfpm:9000;
8967
}
9068

91-
# Fighting with Styles? This little gem is amazing.
92-
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
93-
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
69+
location ~ ^/sites/.*/files/styles/ {
9470
try_files $uri @rewrite;
9571
}
9672

9773
# Handle private files through Drupal. Private file's path can come
9874
# with a language prefix.
99-
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
75+
location ~ ^(/[a-z\-]+)?/system/files/ {
10076
try_files $uri /index.php?$query_string;
10177
}
10278

templates/drupal-9/docker-compose.server.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1+
# itk-version: 1.0.1
12
version: "3"
23

34
networks:
45
frontend:
56
external: true
67
app:
78
driver: bridge
8-
internal: true
9-
external: false
9+
internal: false
1010

1111
services:
1212
phpfpm:
1313
image: itkdev/php7.4-fpm:alpine
1414
restart: unless-stopped
1515
networks:
1616
- app
17-
- frontend
1817
environment:
1918
- PHP_MAX_EXECUTION_TIME=30
2019
- PHP_MEMORY_LIMIT=128M
2120
depends_on:
2221
- memcached
2322
volumes:
2423
- .:/app:delegated
25-
- drush-cache:/root/.drush
2624

2725
nginx:
2826
image: nginx:stable-alpine
@@ -57,20 +55,3 @@ services:
5755
- '11211'
5856
environment:
5957
- MEMCACHED_CACHE_SIZE=64
60-
61-
drush:
62-
image: itkdev/drush6:latest
63-
networks:
64-
- app
65-
- frontend
66-
depends_on:
67-
- mariadb
68-
entrypoint:
69-
- drush
70-
volumes:
71-
- drush-cache:/root/.drush
72-
- ./:/app
73-
74-
# Drush cache volume to persist cache between runs.
75-
volumes:
76-
drush-cache:

0 commit comments

Comments
 (0)