Project: Flagsmith (Observability and Analysis / Feature Flagging)
File: locally-edge-proxy.md

sidebar_label: Edge Proxy title: Edge Proxy sidebar_position: 25 The Edge Proxy can be configured using a json configuration file (named `config.json` here). You can set the following configuration in `config.json` to control the behaviour of the Edge Proxy: An array of environment key pair objects: ```json "environmentkeypairs": [{ "serversidekey": "yourserverside_key", "clientsidekey": "yourclientsideenvironmentkey" }] ``` :::note This setting is optional. ::: Control how often the Edge Proxy is going to ping the server for changes, in seconds: ```json "apipollfrequency": 30 ``` Defaults to `10`. :::note This setting is optional. ::: Specify the request timeout when trying to retrieve new changes, in seconds: ```json "apipolltimeout": 1 ``` Defaults to `5`. :::note This setting is optional. ::: Set if you are running a self hosted version of Flagsmith: ```json "api_url": "https://my-flagsmith.domain.com/api/v1" ``` If not set, defaults to Flagsmith's Edge API. :::note This setting is optional. ::: Set a value for the `Access-Control-Allow-Origin` header. ```json "allow_origins": "https://my-flagsmith.domain.com" ``` If not set, defaults to `*`. :::note This setting is optional. ::: Enable a LRU cache per endpoint. Optionally, specify the LRU cache size with `cachemaxsize` (defaults to 128): ```json "endpoint_caches": { "flags": { "use_cache": false }, "identities": { "use_cache": true, "cachemaxsize": 1000, } } ``` :::note This setting is optional. ::: Choose a logging level from `"CRITICAL"`, `"ERROR"`, `"WARNING"`, `"INFO"`, `"DEBUG"`. Defaults to `"INFO"`. ```json "logging": {"log_level": "DEBUG"} ``` :::note This setting is optional. ::: Choose a logging forman between `"generic"` and `"json"`. Defaults to `"generic"`. ```json "logging": {"log_format": "json"} ``` :::note This setting is optional. ::: Set a name used for human-readable log entry field when logging events in JSON. Defaults to `"message"`. ```json "logging": {"logeventfield_name": "event"} ``` Here's an example of a minimal working Edge Proxy configuration: ```json { "environmentkeypairs": [ { "serversidekey": "yourserversideenvironmentkey", "clientsidekey": "yourclientsideenvironmentkey" } ], "apipollfrequency": 10, "api_url": "https://api.flagsmith.com/api/v1" } ``` You can configure the Edge Proxy with the following Environment Variables: `WEB_CONCURRENCY` The number of workers. Defaults to `1`. Set to the number of available CPU cores. The Edge Proxy runs as a docker container. It is currently available at the . ```bash docker pull flagsmith/edge-proxy docker run \ -v /<path-to-local>/config.json:/app/config.json \ -p 8000:8000 \ flagsmith/edge-proxy:latest ``` ```yml version: '3.9' services: edge_proxy: image: flagsmith/edge-proxy:latest volumes: type: bind source: ./config.json target: /app/config.json ports: target: 8000 published: 8000 ``` The Proxy is now running and available on port 8000. The Edge Proxy provides an identical set of API methods as our Core API. You need to point your SDK to the Edge Proxy domain name and you're good to go. For example, lets say you had your proxy running locally as per the instructions above: ```bash curl "http://localhost:8000/api/v1/flags" -H "x-environment-key: 95DybY5oJoRNhxPZYLrxk4" | jq [ { "enabled": true, "featurestatevalue": 5454, "feature": { "name": "feature_1", "id": 2, "type": "MULTIVARIATE" } }, { "enabled": true, "featurestatevalue": "some_value", "feature": { "name": "feature_2", "id": 9, "type": "STANDARD" } }, ] ``` There are 2 health check endpoints for the Edge Proxy. When making a request to `/proxy/health` the proxy will respond with a HTTP `200` and `{"status": "ok"}`. You can point your orchestration health checks to this endpoint. This endpoint checks that the is not stale, and that the proxy is serving SDK requests. If you are using the Proxy to power Server Sent Events for realtime flag updates. When making a request to `/sse/health` the proxy will respond with a HTTP `200` and `{"status": "ok"}`. The standard Flagsmith architecture: With the proxy added to the mix: