Skip to content

Commit 3e8f286

Browse files
authored
Merge pull request #350 from itk-dev/feature/docker-compose-update
docker compose updates
2 parents d9995e8 + da0b27d commit 3e8f286

File tree

8 files changed

+138
-18
lines changed

8 files changed

+138
-18
lines changed

.docker/nginx.conf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
worker_processes auto;
22

3-
error_log /var/log/nginx/error.log notice;
3+
error_log /dev/stderr notice;
44
pid /tmp/nginx.pid;
55

66
events {
@@ -26,11 +26,9 @@ http {
2626
'$status $body_bytes_sent "$http_referer" '
2727
'"$http_user_agent" "$http_x_forwarded_for"';
2828

29-
access_log /var/log/nginx/access.log main;
29+
access_log /dev/stdout main;
3030

3131
sendfile on;
32-
#tcp_nopush on;
33-
3432
keepalive_timeout 65;
3533

3634
gzip on;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
server {
2+
listen ${NGINX_PORT};
3+
server_name localhost;
4+
5+
root ${NGINX_WEB_ROOT};
6+
7+
location = /favicon.ico {
8+
log_not_found off;
9+
access_log off;
10+
}
11+
12+
location = /robots.txt {
13+
allow all;
14+
log_not_found off;
15+
access_log off;
16+
}
17+
18+
location ~* \.(txt|log)$ {
19+
deny all;
20+
}
21+
22+
location ~ \..*/.*\.php$ {
23+
return 403;
24+
}
25+
26+
location ~ ^/sites/.*/private/ {
27+
return 403;
28+
}
29+
30+
# Block access to scripts in site files directory
31+
location ~ ^/sites/[^/]+/files/.*\.php$ {
32+
deny all;
33+
}
34+
35+
# Block access to "hidden" files and directories whose names begin with a
36+
# period.
37+
location ~ (^|/)\. {
38+
return 403;
39+
}
40+
41+
location / {
42+
try_files $uri /index.php?$query_string;
43+
}
44+
45+
location @rewrite {
46+
rewrite ^ /index.php;
47+
}
48+
49+
# Don't allow direct access to PHP files in the vendor directory.
50+
location ~ /vendor/.*\.php$ {
51+
deny all;
52+
return 404;
53+
}
54+
55+
# Protect files and directories from prying eyes.
56+
location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|.tar|.gz|.bz2|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ {
57+
deny all;
58+
return 404;
59+
}
60+
61+
location ~ '\.php$|^/update.php' {
62+
include fastcgi_params;
63+
64+
fastcgi_buffers 16 32k;
65+
fastcgi_buffer_size 64k;
66+
fastcgi_busy_buffers_size 64k;
67+
68+
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
69+
70+
# Ensure the php file exists. Mitigates CVE-2019-11043
71+
try_files $fastcgi_script_name =404;
72+
73+
fastcgi_param HTTP_PROXY "";
74+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
75+
fastcgi_param PATH_INFO $fastcgi_path_info;
76+
fastcgi_param QUERY_STRING $query_string;
77+
78+
fastcgi_intercept_errors on;
79+
fastcgi_pass ${NGINX_FPM_SERVICE};
80+
81+
# @TODO Can we fall back to the default value here if NGINX_FASTCGI_READ_TIMEOUT is not defined?
82+
# Cf. https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout
83+
fastcgi_read_timeout ${NGINX_FASTCGI_READ_TIMEOUT};
84+
}
85+
86+
# Enforce clean URLs
87+
#
88+
# Removes index.php from urls like www.example.com/index.php/my-page --> www.example.com/my-page
89+
# Could be done with 301 for permanent or other redirect codes.
90+
if ($request_uri ~* "^(.*/)index\.php/(.*)") {
91+
return 307 $1$2;
92+
}
93+
94+
error_log /dev/stderr;
95+
access_log /dev/stdout main;
96+
}

docker-compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# itk-version: 3.1.1
2-
version: "3"
1+
# itk-version: 3.2.0
2+
version: "3.8"
33

44
services:
55
phpfpm:

docker-compose.override.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ services:
88
volumes:
99
- .:/app:delegated
1010
working_dir: /app
11+
12+
phpfpm:
13+
environment:
14+
- PHP_MAX_EXECUTION_TIME=300
15+
- PHP_MEMORY_LIMIT=512M
16+
17+
nginx:
18+
environment:
19+
# Match PHP_MAX_EXECUTION_TIME above
20+
- NGINX_FASTCGI_READ_TIMEOUT=300

docker-compose.redirect.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# itk-version: 3.1.1
2-
version: "3"
1+
# itk-version: 3.2.0
2+
version: "3.8"
33

44
services:
55
nginx:

docker-compose.server.override.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
phpfpm:
3+
environment:
4+
- PHP_MAX_EXECUTION_TIME=300
5+
- PHP_MEMORY_LIMIT=512M
6+
7+
nginx:
8+
environment:
9+
# Match PHP_MAX_EXECUTION_TIME above
10+
- NGINX_FASTCGI_READ_TIMEOUT=300

docker-compose.server.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# itk-version: 3.1.1
2-
version: "3"
1+
# itk-version: 3.2.0
2+
version: "3.8"
33

44
networks:
55
frontend:
@@ -33,12 +33,14 @@ services:
3333
- frontend
3434
depends_on:
3535
- phpfpm
36-
ports:
37-
- '8080'
3836
volumes:
39-
- ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro
37+
- ./.docker/templates:/etc/nginx/templates:ro
4038
- ./.docker/nginx.conf:/etc/nginx/nginx.conf:ro
41-
- ./:/app:rw
39+
- .:/app
40+
environment:
41+
NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000
42+
NGINX_WEB_ROOT: /app/web
43+
NGINX_PORT: 8080
4244
labels:
4345
- "traefik.enable=true"
4446
- "traefik.docker.network=frontend"

docker-compose.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# itk-version: 3.1.1
2-
version: "3"
1+
# itk-version: 3.2.0
2+
version: "3.8"
33

44
networks:
55
frontend:
@@ -35,7 +35,7 @@ services:
3535
- PHP_XDEBUG_MODE=${PHP_XDEBUG_MODE:-off}
3636
- PHP_MAX_EXECUTION_TIME=30
3737
- PHP_MEMORY_LIMIT=256M
38-
# Depending on the setup you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail
38+
# Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail
3939
- PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients
4040
- DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN}
4141
- COMPOSER_VERSION=2
@@ -56,8 +56,12 @@ services:
5656
ports:
5757
- '8080'
5858
volumes:
59-
- ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro
59+
- ./.docker/templates:/etc/nginx/templates:ro
6060
- .:/app
61+
environment:
62+
NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000
63+
NGINX_WEB_ROOT: /app/web
64+
NGINX_PORT: 8080
6165
labels:
6266
- "traefik.enable=true"
6367
- "traefik.docker.network=frontend"

0 commit comments

Comments
 (0)