diff --git a/.github/workflows/reusable-e2e-tests-run.yml b/.github/workflows/reusable-e2e-tests-run.yml index ff7db777462..bbeba3c65bc 100644 --- a/.github/workflows/reusable-e2e-tests-run.yml +++ b/.github/workflows/reusable-e2e-tests-run.yml @@ -50,7 +50,7 @@ jobs: docker-compose- # start necessary containers - - run: docker compose up -d api frontend pdf print browserless database docker-host http-cache mail + - run: docker compose up -d api frontend pdf print browserless database docker-host http-cache mail reverse-proxy # pull cypress while container are starting up - run: docker compose pull e2e diff --git a/api/docker/caddy/Caddyfile b/api/docker/caddy/Caddyfile index bf5924d1f54..2708d88cce6 100644 --- a/api/docker/caddy/Caddyfile +++ b/api/docker/caddy/Caddyfile @@ -1,4 +1,5 @@ { + debug {$CADDY_GLOBAL_OPTIONS} frankenphp { @@ -22,34 +23,6 @@ {$CADDY_EXTRA_CONFIG} -:3000 { - log { - level DEBUG - } - - handle_path /api* { - # rewriting the uri used for php-fcgi did not work - # so we make a hop more to localhost:3001 with the rewritten url where the fcgi happens - # this may slow down the request - - reverse_proxy localhost:3001 { - header_up X-Forwarded-Prefix "/api" - } - } - - handle /print* { - reverse_proxy print:3003 - } - - handle /mail* { - reverse_proxy mail:1080 - } - - handle { - reverse_proxy frontend:3000 - } -} - :3001 { route { root * /app/public diff --git a/api/docker/varnish/vcl/_config.vcl b/api/docker/varnish/vcl/_config.vcl index 980a1cac545..5db396b1a27 100644 --- a/api/docker/varnish/vcl/_config.vcl +++ b/api/docker/varnish/vcl/_config.vcl @@ -1,4 +1,4 @@ backend default { .host = "api"; - .port = "3000"; + .port = "3001"; } \ No newline at end of file diff --git a/api/docker/varnish/vcl/default.vcl b/api/docker/varnish/vcl/default.vcl index 15df5b74722..526d7c1e59b 100644 --- a/api/docker/varnish/vcl/default.vcl +++ b/api/docker/varnish/vcl/default.vcl @@ -20,11 +20,6 @@ sub vcl_recv { # Support xkey purge requests # see https://raw.githubusercontent.com/varnish/varnish-modules/master/src/vmod_xkey.vcc call fos_tags_xkey_recv; - - # exclude other services (frontend, print, etc.) - if (var.get("originalUrl") !~ "^/api") { - return(pass); - } # exclude API documentation, profiler and graphql endpoint if (var.get("originalUrl") ~ "^/api/docs" @@ -100,4 +95,3 @@ sub vcl_deliver { set resp.http.Cache-Control = "no-cache, private"; } } - diff --git a/docker-compose.yml b/docker-compose.yml index 1108cc4b116..c8b7c2690a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,9 +36,6 @@ services: - database - docker-host ports: - - target: 3000 - published: 3000 - protocol: tcp - target: 2019 published: 2019 protocol: tcp @@ -81,10 +78,6 @@ services: - api volumes: - ./api/docker/varnish/vcl/:/etc/varnish/:ro - ports: - - target: 8080 - published: 3004 - protocol: tcp command: -a :8081,HTTP -p http_max_hdr=96 environment: - COOKIE_PREFIX=localhost_ @@ -192,6 +185,22 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw network_mode: host working_dir: /e2e + + reverse-proxy: + image: nginx:1.26 + container_name: 'ecamp3-reverse-proxy' + volumes: + - ./reverse-proxy-nginx.conf:/etc/nginx/nginx.conf + depends_on: + - frontend + - api + ports: + - target: 3000 + published: 3000 + protocol: tcp + - target: 3004 + published: 3004 + protocol: tcp translation: image: node:22.4.1 diff --git a/print/print.env b/print/print.env index 04e3244978d..b98ed4ac4a3 100644 --- a/print/print.env +++ b/print/print.env @@ -1,4 +1,4 @@ -NUXT_INTERNAL_API_ROOT_URL=http://http-cache:8080/api +NUXT_INTERNAL_API_ROOT_URL=http://http-cache:8080 NUXT_SENTRY_PRINT_DSN= NUXT_SENTRY_ENVIRONMENT=local NUXT_BROWSER_WS_ENDPOINT=ws://browserless:3000 diff --git a/reverse-proxy-nginx.conf b/reverse-proxy-nginx.conf new file mode 100644 index 00000000000..eccbd8df6f3 --- /dev/null +++ b/reverse-proxy-nginx.conf @@ -0,0 +1,70 @@ +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + resolver 127.0.0.11; + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 3000; + server_name localhost; + + location / { + proxy_pass http://frontend:3000; + } + + location /api/ { + # the Set-Cookie: XDEBUG_SESSION=PHPSTORM; path=/; SameSite=Lax header is set too many times + # temporary workaround from https://stackoverflow.com/a/27551259 + proxy_buffer_size 128k; + proxy_buffers 4 256k; + proxy_busy_buffers_size 256k; + proxy_set_header X-Forwarded-Prefix /api; + proxy_pass http://api:3001/; + } + + location /print { + proxy_pass http://print:3003; + } + + location /mail { + proxy_pass http://mail:1080; + } + } + server { + listen 3004; + server_name localhost; + + location / { + proxy_pass http://frontend:3000; + } + + location /api/ { + # the Set-Cookie: XDEBUG_SESSION=PHPSTORM; path=/; SameSite=Lax header is set too many times + # temporary workaround from https://stackoverflow.com/a/27551259 + proxy_buffer_size 128k; + proxy_buffers 4 256k; + proxy_busy_buffers_size 256k; + proxy_set_header X-Forwarded-Prefix /api; + proxy_pass http://http-cache:8080/; + } + + location /print { + proxy_pass http://print:3003; + } + + location /mail { + proxy_pass http://mail:1080; + } + } +}