Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
3.7 KB
Raw Blame
apiVersion: v1
kind: ConfigMap
metadata:
  name: external-rest-api-config
  namespace: profiles
data:
  EXTERNAL_REST_API_JSON_BODY_LIMIT: 150mb
  # Coarse edge backstop capacity for GFS traffic behind one trusted proxy.
  # Authoritative per-session/actor budgets remain in control-api.
  EXTERNAL_REST_API_GFS_EDGE_AGGREGATE_RL_PER_MIN: '1800'
  EXTERNAL_REST_API_GFS_EDGE_AUTHENTICATED_IP_RL_PER_MIN: '1200'
  EXTERNAL_REST_API_GFS_EDGE_TOKEN_IP_RL_PER_MIN: '600'
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: profile-control-funnel-nginx
  namespace: profiles
data:
  nginx.conf: |
    pid /tmp/nginx.pid;
    events {}
    http {
      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;

      resolver kube-dns.kube-system.svc.cluster.local valid=10s ipv6=off;

      # nginx defaults client_max_body_size to 1m. Keep the legacy JSON path at
      # its 24MiB cap; v2 parts are raw streamed requests and each is <=16MiB,
      # so this gateway cap stays above the per-request contract without becoming
      # a 200MiB whole-file allowance.
      client_max_body_size 25165824;

      # Homologate the funnel's idle timers with the 300s deadline the rest of the
      # me-path uses (nginx defaults each to 60s). Without these the funnel is the
      # one hop that 504s a large upload/download that every downstream hop would
      # still wait 300s for.
      proxy_read_timeout 300s;
      proxy_send_timeout 300s;
      client_body_timeout 300s;

      server {
        listen 8080;

        location = /health {
          return 200 "ok\n";
        }

        # Allow only external-rest-api internal control calls.
        location ~ ^/api/v1/external/ {
          set $control_api_origin control-api.control-plane.svc.cluster.local:8090;
          proxy_pass http://$control_api_origin$request_uri;
          proxy_http_version 1.1;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
        }

        # Public OAuth callback: provider → external-rest-api (passthrough) → here
        # → control-api. control-api's /api/v1/oauth-callback/<oauthClientId> is
        # state-authenticated (no service token), so it is exposed by path here
        # alongside the /external/ internal surface rather than via a new gateway.
        location ~ ^/api/v1/oauth-callback/ {
          set $control_api_origin control-api.control-plane.svc.cluster.local:8090;
          proxy_pass http://$control_api_origin$request_uri;
          proxy_http_version 1.1;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
        }

        # Public CIMD (SEP-991) document: the remote MCP-OAuth client_id is
        # <public origin>/api/v1/.well-known/evenfire-mcp-client, fetched by the
        # remote Authorization Server via external-rest-api. Exact path only,
        # read-only (limit_except GET also admits HEAD), no query forwarded.
        location = /api/v1/.well-known/evenfire-mcp-client {
          limit_except GET {
            deny all;
          }
          set $control_api_origin control-api.control-plane.svc.cluster.local:8090;
          proxy_pass http://$control_api_origin/api/v1/.well-known/evenfire-mcp-client;
          proxy_http_version 1.1;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
        }

        location / {
          return 403;
        }
      }
    }