From dd3e3b28eb19511ecf279822f835a15e2c928759 Mon Sep 17 00:00:00 2001 From: nfebe Date: Sat, 18 Apr 2026 02:01:32 +0100 Subject: [PATCH 1/2] fix(ui): Proxy agent API calls from the UI container The UI image now forwards /api/ and /health requests to the FlatRun agent instead of returning 404, restoring connectivity when the image replaces the host nginx that previously performed the proxy. The agent endpoint is configurable via the AGENT_URL environment variable and defaults to host.docker.internal:8090 so the image works against an agent running on the docker host without extra wiring. --- Dockerfile | 5 ++++- nginx.conf | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9c8e5ee..670577d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,9 @@ LABEL org.opencontainers.image.title="FlatRun UI" \ org.opencontainers.image.url="https://github.com/flatrun/ui" \ org.opencontainers.image.documentation="https://github.com/flatrun/ui#readme" +ENV AGENT_URL=http://host.docker.internal:8090 \ + NGINX_ENVSUBST_FILTER=AGENT_URL + COPY --from=build /app/dist /usr/share/nginx/html -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/templates/default.conf.template EXPOSE 80 diff --git a/nginx.conf b/nginx.conf index 5c5f7f1..bfce3a8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -17,4 +17,37 @@ server { expires 30d; add_header Cache-Control "public"; } + + location /api/ { + proxy_pass ${AGENT_URL}; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 300s; + proxy_buffering off; + } + + location /api/containers { + proxy_pass ${AGENT_URL}; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; + proxy_buffering off; + } + + location /health { + proxy_pass ${AGENT_URL}/api/health; + proxy_http_version 1.1; + proxy_set_header Host $host; + } } From 1cd982b2419d30a3cf141d1faa793aac8a87d617 Mon Sep 17 00:00:00 2001 From: nfebe Date: Sat, 18 Apr 2026 02:19:34 +0100 Subject: [PATCH 2/2] refactor(ui): Simplify nginx config to match installer's pattern Collapses the separate API location blocks and the /health rewrite into a single /api block that already covers websocket upgrades and long-lived streams, mirroring the config the installer generates when the UI is deployed from a dist folder. The /assets block is also dropped since the SPA's content-hashed filenames do not need a dedicated caching tier to behave correctly. --- nginx.conf | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/nginx.conf b/nginx.conf index bfce3a8..7da26bd 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,6 +1,5 @@ server { - listen 80 default_server; - listen [::]:80 default_server; + listen 80; server_name _; root /usr/share/nginx/html; @@ -8,46 +7,18 @@ server { client_max_body_size 100M; - location / { - try_files $uri $uri/ /index.html; - add_header Cache-Control "no-cache"; - } - - location /assets/ { - expires 30d; - add_header Cache-Control "public"; - } - - location /api/ { + location /api { proxy_pass ${AGENT_URL}; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 300s; - proxy_buffering off; - } - - location /api/containers { - proxy_pass ${AGENT_URL}; - proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; proxy_read_timeout 3600s; - proxy_send_timeout 3600s; - proxy_buffering off; } - location /health { - proxy_pass ${AGENT_URL}/api/health; - proxy_http_version 1.1; - proxy_set_header Host $host; + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; } }