Skip to content

Commit 25464d8

Browse files
committed
1284: Added PethPrefix scope to traefik rules to allow co-hosting with legacy eventdb
1 parent 2c82d5b commit 25464d8

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.docker/templates/default.conf.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ server {
55
root ${NGINX_WEB_ROOT};
66

77
location / {
8+
# We are co-hosting with the legacy EventDB, so this app is hosted under '/api/v2/' (.env::APP_PATH_PREFIX)
9+
# This is configured for Symfony in both 'api_platform.prefix' and 'framework.assets.base_path'. However
10+
# Symfony still installs assets in the root path so we need to rewrite the uri to remove '/api/v2/'.
11+
rewrite ^${APP_PATH_PREFIX}/(.*) /$1 break;
12+
813
# try to serve file directly, fallback to index.php
914
try_files $uri /index.php$is_args$args;
1015
}

config/packages/framework.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ framework:
1818
php_errors:
1919
log: true
2020

21+
assets:
22+
base_path: '%env(APP_PATH_PREFIX)%'
23+
2124
when@test:
2225
framework:
2326
test: true

docker-compose.override.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ services:
1818
- RABBITMQ_DEFAULT_PASS=password
1919
- RABBITMQ_ERLANG_COOKIE='d53f319cd7376f8f840aaf9889f315ab
2020

21+
nginx:
22+
environment:
23+
APP_PATH_PREFIX: ${APP_PATH_PREFIX}
24+
labels:
25+
# Scope hosting by path prefix to allow shared hosting with legacy EventDB
26+
# 'https://api.detskeriaarhus.dk/api/' -> Legacy EventDB
27+
# 'https://api.detskeriaarhus.dk/api/v2/' -> EventDB v2
28+
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`${COMPOSE_DOMAIN}`) && PathPrefix(`${APP_PATH_PREFIX}`)"
29+
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`) && PathPrefix(`${APP_PATH_PREFIX}`)"
30+
2131
elasticsearch:
2232
image: elasticsearch:8.13.0
2333
networks:
@@ -34,4 +44,3 @@ services:
3444
environment:
3545
- discovery.type=single-node
3646
- xpack.security.enabled=false
37-

docker-compose.server.override.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ networks:
99

1010
services:
1111
nginx:
12+
environment:
13+
APP_PATH_PREFIX: ${APP_PATH_PREFIX}
1214
labels:
1315
# Scope hosting by path prefix to allow shared hosting with legacy EventDB
1416
# 'https://api.detskeriaarhus.dk/api/' -> Legacy EventDB

0 commit comments

Comments
 (0)