Skip to content

Add API reverse proxy to webapp nginx config - #13

Open
eljeffeg wants to merge 1 commit into
ad-freiburg:mainfrom
eljeffeg:nginx
Open

Add API reverse proxy to webapp nginx config#13
eljeffeg wants to merge 1 commit into
ad-freiburg:mainfrom
eljeffeg:nginx

Conversation

@eljeffeg

@eljeffeg eljeffeg commented Jun 5, 2026

Copy link
Copy Markdown

Problem

When running the webapp and GRASP backend as separate containers, the Svelte app makes all API calls to /api/* (baked in at build time via API_BASE=/api). Without a proxy, nginx would attempt to serve those paths as static files and return 404 for every API call and WebSocket connection.

Solution

Added two location blocks to apps/grasp/nginx.conf:

  • location /api/ — proxies HTTP API requests to the GRASP backend, stripping the /api prefix:
    GET /api/knowledge_graphshttp://grasp:6789/knowledge_graphs

  • location /api/live — proxies the WebSocket streaming endpoint with the required Upgrade/Connection headers so nginx hands off the persistent connection rather than treating it as a plain HTTP request.

Both blocks forward X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto so the backend sees correct client information.

Result

The webapp container on port 80 is the single entry point. The browser never needs direct access to the GRASP backend port; nginx routes static files and API calls appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant