river 0.2.1

A reverse proxy application, based on the pingora library from Cloudflare
# Test configuration file
#
# This is more in depth than the example.
#
# NOTE: Until we have made a release, configuration format should
# be considered entirely unstable, and likely to make breaking changes
# commit-to-commit!

[system]
# Threads per service
threads-per-service = 8

# Specify a Basic Proxy service, which features minimal configuration.
#
# Note that indentation isn't significant in TOML, it is only done
# here to note the structure of the data.
#
# TODO: This data is very structured, and TOML might not be a good fit.
[[basic-proxy]]
name = "Example1"

    # Each `basic-proxy` can have one or more Listeners, or downstream
    # connections. If you provide zero, the basic proxy will terminate
    # immediately.
    [[basic-proxy.listeners]]
        # TODO: "listeners" only has one field, we might want to use
        # serde flatten
        [basic-proxy.listeners.source]
        # Listeners can have kind of "Tcp" (w/ or w/o TLS) or "Uds"
        # for "Unix Domain Sockets", which cannot have TLS.
        kind = "Tcp"
            [basic-proxy.listeners.source.value]
            # TCP must specify the address, which includes the port to bind to
            addr = "0.0.0.0:8080"

    # `basic-proxy`s can have multiple listeners
    [[basic-proxy.listeners]]

        [basic-proxy.listeners.source]
        kind = "Tcp"

        [basic-proxy.listeners.source.value]
        addr = "0.0.0.0:4443"

            # To enable TLS, specify the path to the certificate and key
            [basic-proxy.listeners.source.value.tls]
            cert_path = "./assets/test.crt"
            key_path = "./assets/test.key"

    # Each `basic proxy` must have exactly one "connector", or the upstream
    # server they will proxy to.
    #
    # To use TLS for upstream connections, specify the SNI of the connection
    [basic-proxy.connector]
    proxy_addr = "91.107.223.4:443"
    tls_sni = "onevariable.com"

    # "Path Control" affects requests and responses as they are proxied
    [basic-proxy.path-control]
    # upstream request filters specifically allow for the cancellation or modification
    # of requests, as they are being made.
    #
    # Filters are applied in the order they are specified. Multiple instances of
    # each filter may be provided.
    upstream-request-filters = [
        # Remove any headers with keys matching `pattern`
        { kind = "remove-header-key-regex", pattern = ".*(secret|SECRET).*" },
        # Add or replace (e.g. "Upsert") a fixed header with the given key and value
        { kind = "upsert-header", key = "x-proxy-friend", value = "river" },
    ]

    upstream-response-filters = [
        # Remove any headers with keys matching `pattern`
        { kind = "remove-header-key-regex", pattern = ".*ETag.*" },
        # Add or replace (e.g. "Upsert") a fixed header with the given key and value
        { kind = "upsert-header", key = "x-with-love-from", value = "river" },
    ]

# We specify a second basic proxy as well. Here we use the other table syntax
[[basic-proxy]]
name = "Example2"
listeners = [
    { source = { kind = "Tcp", value = { addr = "0.0.0.0:8000" } } }
]
connector = { proxy_addr = "91.107.223.4:80" }