Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

4.1 KB
Raw Blame
# Test-only nginx config for the frontend container. Mounted over
# /etc/nginx/nginx.conf by docker-compose.test.yaml.
#
# WHY THIS EXISTS
# The `ui` Playwright group drives a real browser at the frontend's own origin,
# and the app builds every API URL from `window.location.origin` — see
# `getBaseUrl()` in frontend/src/helpers/GetStaticData.js. The production config
# serves static files plus an SPA fallback and nothing else, so `/api/v1/*`
# returned index.html: session setup failed and every authenticated spec landed
# on the login screen while the document-only smoke test still passed.
#
# A developer avoids this by reaching the app through Traefik at
# `frontend.unstract.localhost`, which docker-compose.yaml already labels to
# route /api/v1, /deployment and /public to the backend. The rig cannot use that
# origin: `*.localhost` resolves to ::1 for Node's resolver while compose
# publishes IPv4 only, so fixtures.js would get ECONNREFUSED. Proxying at :3000
# keeps the suite on one deterministic origin.
#
# THIS IS NOT A MIRROR OF frontend/nginx.conf. It is deliberately minimal — one
# origin for the suite, not a reproduction of the production cache and security
# headers. Do not sync changes between the two files in either direction.

worker_processes  auto;
# The image runs as USER nginx, which cannot write the default /var/run prefix.
pid        /tmp/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log  /dev/stdout;
    sendfile    on;
    keepalive_timeout  65;

    # Same reason as `pid` above: the nginx user has no access to /var/cache.
    client_body_temp_path   /tmp/client_temp;
    proxy_temp_path         /tmp/proxy_temp;
    fastcgi_temp_path       /tmp/fastcgi_temp;
    uwsgi_temp_path         /tmp/uwsgi_temp;
    scgi_temp_path          /tmp/scgi_temp;

    server {
        listen 80;
        root  /usr/share/nginx/html;

        # Docker's embedded DNS. Resolving through a variable rather than
        # inlining the host in proxy_pass means nginx does NOT resolve `backend`
        # at startup, so the frontend still boots when it wins the race against
        # the backend container (`depends_on` waits for start, not readiness).
        resolver 127.0.0.11 valid=10s ipv6=off;
        set $backend_upstream http://backend:8000;

        # The three prefixes Traefik sends to the backend in
        # docker/docker-compose.yaml. Written as prefix matches without a
        # trailing slash so they behave like that file's PathPrefix() rules
        # (`/api/v1` itself matches, not just `/api/v1/...`). Keep the list
        # in step with those labels.
        location /api/v1 {
            proxy_pass $backend_upstream$request_uri;
            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;
            # File uploads: the default 1m rejects the fixtures' sample PDFs.
            client_max_body_size 100m;
            proxy_read_timeout 300s;
        }

        location /deployment {
            proxy_pass $backend_upstream$request_uri;
            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;
            client_max_body_size 100m;
            proxy_read_timeout 300s;
        }

        location /public {
            proxy_pass $backend_upstream$request_uri;
            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;
        }

        location /assets/ {
            try_files $uri =404;
        }

        # SPA fallback, as in production: a React route is not a file on disk.
        location / {
            try_files $uri /index.html;
        }
    }
}