envoy-guide
Module 2 · Your First Envoy·12 min·beginner

Listeners, filters, and the HCM

Follow a request from the socket to the router filter.

The path of a request

Every HTTP request that hits Envoy walks the same pipeline:

Three things to internalize:

  1. A listener binds a port. One Envoy can have many listeners.
  2. The HCM is itself a network filter — it sits inside the listener's filter chain and turns raw bytes into HTTP requests.
  3. Inside the HCM is its own chain of HTTP filters. The last one is always envoy.filters.http.router — it's the filter that actually sends the request upstream.

A real, runnable hello-world

This is the canonical first Envoy config: listen on port 10000, proxy everything to httpbin.org.

YAML
admin:
  address:
    socket_address: { address: 0.0.0.0, port_value: 9901 }

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0, port_value: 10000 }
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route:
                  cluster: httpbin
                  host_rewrite_literal: httpbin.org

  clusters:
  - name: httpbin
    type: LOGICAL_DNS
    connect_timeout: 1s
    load_assignment:
      cluster_name: httpbin
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address: { address: httpbin.org, port_value: 80 }

Yes, it's verbose. Yes, the @type URLs feel like punishment. Both go away once you stop reading them and start recognizing the shape of the config.

Hands-on · Run the hello-world

Save the config above as envoy.yaml, then:

Shell
docker run --rm -it \
  -p 10000:10000 -p 9901:9901 \
  -v "$PWD/envoy.yaml:/etc/envoy/envoy.yaml" \
  envoyproxy/envoy:v1.31-latest

In another terminal:

Shell
curl -s localhost:10000/get | head -20

You're hitting Envoy on port 10000; Envoy is calling httpbin.org for you and streaming the response back. Your first reverse-proxy config — done.

Now visit http://localhost:9901/clusters and find your httpbin cluster with its single endpoint and active health. That's the same data Envoy maintains for every cluster, no matter how complex things get later.

The router filter must be last

If you forget envoy.filters.http.router or put another HTTP filter after it, requests will hang or return errors. The router is the terminal filter — it's what actually dispatches to the upstream. Every HTTP filter chain ends with it.

The mental model that pays off

Once you see the pipeline as listener → filter chain → HCM → HTTP filters → router → cluster, every Envoy feature you'll meet later just slots into one of those boxes:

  • TLS termination? A transport_socket on the filter chain.
  • Rate limiting / JWT auth / ext-authz? HTTP filters before router.
  • Load balancing? Inside the cluster.
  • Path rewrites, weighted canary? On the route.
  • Health checks, circuit breakers? On the cluster too.

Same skeleton, more filling.

Real-world example · Envoy Gateway / Emissary-ingress
Problem
An API gateway team needs JWT auth, rate limiting, header transforms, and request mirroring on every public route — composable per route, with nothing baked into application code.
Envoy solution
They configure Envoy's HTTP filter chain to include jwt_authn, local_ratelimit, header manipulation, and request_mirror_policies, all upstream of the router. The same pipeline you wrote above, just with more filters between the HCM and the router.

Try breaking it on purpose

A surprising amount of Envoy intuition comes from watching it fail clearly.

Tip

After the curl works, comment out the envoy.filters.http.router block and restart. Send another request. Read the error. Now put it back. You'll never forget that the router has to be there.

Quick check

Where must `envoy.filters.http.router` appear in your HTTP filter chain?

Practical task
Finish the quick check and tick off the task to unlock.
Quick checkTasks 0/3