Deploy the HTTP proxy

This guide runs featuremeshd's HTTP proxy, which lets a client of a warehouse's HTTP API send FeatureQL without changing its code. Only its proxy setting changes.

What the proxy does

The proxy sits between your SQL clients and your warehouses' HTTP APIs. featuremeshd runs Envoy, and Envoy runs one middleware per warehouse.

  1. A client sends a query request to a warehouse domain you configured, through the proxy.
  2. The middleware takes the statement from the request, and sends it to the registry with the warehouse's backend.
  3. The registry translates it to SQL for that backend.
  4. The middleware puts the SQL in the request, and the proxy forwards it to the warehouse.

The warehouse runs the query and answers the client directly through the proxy. The client's own credentials, such as its Authorization header, pass through unchanged. The proxy holds no warehouse credential.

Every statement of a matched request goes to the registry. Route through the proxy only the clients that send FeatureQL or hybrid queries ( Hybrid queries ).

MiddlewareRequests it rewrites
bigqueryPOST …/projects/<project>/queries and …/jobs. It also answers the dataset and table listings with FeatureMesh namespaces
trinoPOST /v1/statement, when the X-Trino-Catalog header is fm or absent. It forwards to a real Trino cluster
snowflakePOST /queries/v1/query-request, its sqlText field
databricksThrift ExecuteStatement, and POST /api/2.0/sql/statements
clickhousePOST / without a query parameter. A trailing FORMAT clause is kept
debugnone. It logs every request and response, with authentication and cookie headers masked

A request to a domain that no route names passes through unchanged.

When to deploy it

Deploy the proxy when a BI tool, a notebook or a driver talks to a warehouse over HTTP, and should run FeatureQL without a FeatureMesh client. It is a service of its own. It needs no serving or hooks pods, and they do not need it.

Before you start, have:

  • your registry's endpoint and token ( Configure featuremeshd );
  • network access from the proxy to the registry and to each warehouse endpoint;
  • for HTTPS clients, a certificate authority (a certificate and its key) that your clients trust (§ 2).

1. Write the configuration

The proxy section of featuremeshd's file declares the listeners and one route per warehouse domain:

proxy:
  enabled: true
  listeners:
    http:
      address: "0.0.0.0:10080"
    https:
      address: "0.0.0.0:10443"
      tls:
        certificate: "/etc/featuremeshd/ca/ca.crt"
        key: "/etc/featuremeshd/ca/ca.key"
  routes:
    - domain: "bigquery.googleapis.com"
      target:
        address: "bigquery.googleapis.com:443"
        tls: true
      middlewares:
        - name: bigquery
health:
  enabled: true
  address: "0.0.0.0:10094"
yaml
KeyDefault
proxy.enabledfalsestarts Envoy and the middlewares
proxy.listenershttp on 0.0.0.0:10080, https on 0.0.0.0:10443a map keyed by http or https. Another key stops featuremeshd at start
proxy.listeners.<protocol>.addressthe listener's address
proxy.listeners.https.tls.certificate, .keynonethe certificate authority the proxy signs each route's certificate with (§ 2). A declared https listener without tls is refused
proxy.routes[].domainthe warehouse host name clients ask for. It matches <domain> and <domain>:<port>
proxy.routes[].target.addresshost:port the request is forwarded to
proxy.routes[].target.tlsfalseforward over TLS, with the domain as SNI
proxy.routes[].tls_certificatenonecertificate_chain and private_key files that replace the certificate the proxy signs for this domain
proxy.routes[].middlewares[].namebigquery, trino, snowflake, databricks, clickhouse or debug
proxy.routes[].middlewares[].wasm/etc/featuremeshd/middlewares/<name>.wasmthe middleware's file. The image ships all six there
proxy.routes[].middlewares[].confignonethe middleware's settings, as a JSON string. Invalid JSON stops featuremeshd at start

Two environment variables set the logs of the middlewares:

VariableDefault
FEATUREMESHD_PROXY_ENVOY_LOG_LEVELoffthe middlewares' log level. At off, they log nothing
FEATUREMESHD_PROXY_ENVOY_LOG_FORMATtext, pretty or json

featuremeshd writes Envoy's files, envoy.yaml, lds.yaml and cds.yaml, into its data directory (FEATUREMESHD_DATA_DIR, /tmp/featuremeshd by default). Read them to see the listeners and routes it built.

2. Prepare the certificate authority

An HTTPS client sends CONNECT through the proxy, and expects the warehouse's certificate. The proxy answers for each route's domain with a certificate it signs with the listener's certificate authority. So the client must trust that authority:

  • create a certificate authority for the proxy alone, and keep its key in a secret;
  • add its certificate to the trust store of every client that uses the proxy;
  • or give a route its own tls_certificate, which the clients already trust.

A cleartext client, HTTP_PROXY, needs none of this. The proxy forwards its request over TLS when the route says target.tls: true.

3. Run it

The image ghcr.io/featuremesh/featuremeshd holds featuremeshd, Envoy and the six middlewares. Run it with the registry connection and the file:

docker run -d --name featuremeshd-proxy -p 10080:10080 -p 10443:10443 -p 10094:10094 \
  -e FEATUREMESHD_REGISTRY_URL=https://registry.example.com \
  -e FEATUREMESHD_REGISTRY_TOKEN="$REGISTRY_TOKEN" \
  -e FEATUREMESHD_CONFIG_PATH=/etc/featuremeshd/config.yaml \
  -v "$PWD/config.yaml:/etc/featuremeshd/config.yaml:ro" \
  -v "$PWD/ca:/etc/featuremeshd/ca:ro" \
  ghcr.io/featuremesh/featuremeshd
bash

On Kubernetes, run the same image in a Deployment of your own, with the token from a secret, the file and the authority mounted, and a Service on 10080 and 10443. The featuremeshd Helm chart's service: proxy does not start a working proxy in this version. Use the chart for serving and hooks only ( Deploy featuremeshd ).

Keep the ports reachable by your SQL clients only, as for featuremeshd's other ports ( Protect the port ).

4. Point the clients at it

Set the client's proxy, not its endpoint. The client keeps the warehouse's URL:

export HTTP_PROXY=http://featuremeshd-proxy:10080
export HTTPS_PROXY=http://featuremeshd-proxy:10080
bash

An HTTPS request arrives as CONNECT on 10080, and is handed to the HTTPS listener.

Check the proxy

  • The process runs. GET /health on port 10094 answers {"status":"healthy"}, with the health section above. The proxy has no other health endpoint, and no Envoy admin port.
  • A statement is translated. Start with FEATUREMESHD_PROXY_ENVOY_LOG_LEVEL=info, send a FeatureQL query from a client, and look for a log line Request #<n> is a … statement. The warehouse runs SQL, and the client gets rows.
  • HTTPS works. The client connects without a certificate error.

Common failures

  • The warehouse rejects FeatureQL as a syntax error: the proxy could not reach the registry, and forwarded the request untranslated. Its log says Request #<n> was forwarded untranslated, with the reason. Check FEATUREMESHD_REGISTRY_URL and the network path. The proxy keeps only the URL's host and port.
  • The client gets an error in the warehouse's format, such as a Trino error or a Snowflake success: false: the registry refused the statement. The message is the registry's.
  • A certificate error on HTTPS: the client does not trust the proxy's certificate authority (§ 2).
  • featuremeshd stops at start: the file declares an https listener without tls, a listener key other than http or https, or a middleware config that is not valid JSON.
  • No middleware logs: FEATUREMESHD_PROXY_ENVOY_LOG_LEVEL is off by default.

Related