Run Envoy

The following instructions walk through starting Envoy as a system daemon or using the Envoy Docker image.

Check your Envoy version

Once you have installed Envoy, you can check the version information as follows:

SystemDocker (Linux Image)Docker (Windows Image)

  1. $ envoy --version
  2. ...
  1. $ docker run --rm \
  2. envoyproxy/envoy:v1.22.6 \
  3. --version
  4. ...
  1. PS> docker run --rm
  2. 'envoyproxy/envoy-windows:v1.22.6'
  3. --version
  4. ...

View the Envoy command line options

You can view the Envoy command line options with the --help flag:

SystemDocker (Linux Image)Docker (Windows Image)

  1. $ envoy --help
  2. ...
  1. $ docker run --rm \
  2. envoyproxy/envoy:v1.22.6 \
  3. --help
  4. ...
  1. PS> docker run --rm
  2. 'envoyproxy/envoy-windows:v1.22.6'
  3. --help
  4. ...

Run Envoy with the demo configuration

The -c or --config-path flag tells Envoy the path to its initial configuration.

Envoy will parse the config file according to the file extension, please see the config path command line option for further information.

SystemDocker (Linux Image)Docker (Windows Image)

To start Envoy as a system daemon download the demo configuration, and start as follows:

  1. $ envoy -c envoy-demo.yaml
  2. ...

You can start the Envoy Docker image without specifying a configuration file, and it will use the demo config by default.

  1. $ docker run --rm -it \
  2. -p 9901:9901 \
  3. -p 10000:10000 \
  4. envoyproxy/envoy:v1.22.6
  5. ...

To specify a custom configuration you can mount the config into the container, and specify the path with -c.

Assuming you have a custom configuration in the current directory named envoy-custom.yaml:

  1. $ docker run --rm -it \
  2. -v $(pwd)/envoy-custom.yaml:/envoy-custom.yaml \
  3. -p 9901:9901 \
  4. -p 10000:10000 \
  5. envoyproxy/envoy:v1.22.6 \
  6. -c /envoy-custom.yaml
  7. ...

You can start the Envoy Docker image without specifying a configuration file, and it will use the demo config by default.

  1. PS> docker run --rm -it
  2. -p '9901:9901'
  3. -p '10000:10000'
  4. 'envoyproxy/envoy-windows:v1.22.6'
  5. ...

To specify a custom configuration you can mount the config into the container, and specify the path with -c.

Assuming you have a custom configuration in the current directory named envoy-custom.yaml, from PowerShell run:

  1. PS> docker run --rm -it
  2. -v "$PWD\:`"C:\envoy-configs`""
  3. -p '9901:9901'
  4. -p '10000:10000'
  5. 'envoyproxy/envoy-windows:v1.22.6'
  6. -c 'C:\envoy-configs\envoy-custom.yaml'
  7. ...

Check Envoy is proxying on http://localhost:10000.

  1. $ curl -v localhost:10000
  2. ...

You can exit the server with Ctrl-c.

See the admin quick start guide for more information about the Envoy admin interface.

Override the default configuration

You can provide an override configuration using --config-yaml which will merge with the main configuration.

This option can only be specified once.

Save the following snippet to envoy-override.yaml:

  1. admin:
  2. address:
  3. socket_address:
  4. address: 127.0.0.1
  5. port_value: 9902

Warning

If you run Envoy inside a Docker container you may wish to use 0.0.0.0. Exposing the admin interface in this way may give unintended control of your Envoy server. Please see the admin section for more information.

Next, start the Envoy server using the override configuration:

SystemDocker (Linux Image)Docker (Windows Image)

On Linux/Mac: run:

  1. $ envoy -c envoy-demo.yaml --config-yaml "$(cat envoy-override.yaml)"
  2. ...

On Windows run:

  1. $ envoy -c envoy-demo.yaml --config-yaml "$(Get-Content -Raw envoy-override.yaml)"
  2. ...
  1. $ docker run --rm -it \
  2. -p 9902:9902 \
  3. -p 10000:10000 \
  4. envoyproxy/envoy:v1.22.6 \
  5. -c /etc/envoy/envoy.yaml \
  6. --config-yaml "$(cat envoy-override.yaml)"
  7. ...
  1. PS> docker run --rm -it
  2. -p '9902:9902'
  3. -p '10000:10000'
  4. 'envoyproxy/envoy-windows:v1.22.6'
  5. -c 'C:\ProgramData\envoy.yaml'
  6. --config-yaml "$(Get-Content -Raw envoy-override.yaml)"
  7. ...

The Envoy admin interface should now be available on http://localhost:9902.

  1. $ curl -v localhost:9902
  2. ...

Note

When merging yaml lists (e.g. listeners or clusters) the merged configurations are appended.

You cannot therefore use an override file to change the configurations of previously specified listeners or clusters

Validating your Envoy configuration

You can start Envoy in validate mode.

This allows you to check that Envoy is able to start with your configuration, without actually starting or restarting the service, or making any network connections.

If the configuration is valid the process will print OK and exit with a return code of 0.

For invalid configuration the process will print the errors and exit with 1.

SystemDocker (Linux Image)Docker (Windows Image)

  1. $ envoy --mode validate -c my-envoy-config.yaml
  2. [2020-11-08 12:36:06.543][11][info][main] [source/server/server.cc:583] runtime: layers:
  3. - name: base
  4. static_layer:
  5. {}
  6. - name: admin
  7. admin_layer:
  8. {}
  9. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:95] loading tracing configuration
  10. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:70] loading 0 static secret(s)
  11. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:76] loading 1 cluster(s)
  12. [2020-11-08 12:36:06.546][11][info][config] [source/server/configuration_impl.cc:80] loading 1 listener(s)
  13. [2020-11-08 12:36:06.549][11][info][config] [source/server/configuration_impl.cc:121] loading stats sink configuration
  14. configuration 'my-envoy-config.yaml' OK
  1. $ docker run --rm \
  2. -v $(pwd)/my-envoy-config.yaml:/my-envoy-config.yaml \
  3. envoyproxy/envoy:v1.22.6 \
  4. --mode validate \
  5. -c my-envoy-config.yaml
  6. [2020-11-08 12:36:06.543][11][info][main] [source/server/server.cc:583] runtime: layers:
  7. - name: base
  8. static_layer:
  9. {}
  10. - name: admin
  11. admin_layer:
  12. {}
  13. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:95] loading tracing configuration
  14. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:70] loading 0 static secret(s)
  15. [2020-11-08 12:36:06.543][11][info][config] [source/server/configuration_impl.cc:76] loading 1 cluster(s)
  16. [2020-11-08 12:36:06.546][11][info][config] [source/server/configuration_impl.cc:80] loading 1 listener(s)
  17. [2020-11-08 12:36:06.549][11][info][config] [source/server/configuration_impl.cc:121] loading stats sink configuration
  18. configuration 'my-envoy-config.yaml' OK
  1. PS> docker run --rm -it
  2. -v "$PWD\:`"C:\envoy-configs`""
  3. -p '9901:9901'
  4. -p '10000:10000'
  5. 'envoyproxy/envoy-windows:v1.22.6'
  6. --mode validate
  7. -c 'C:\envoy-configs\my-envoy-config.yaml'
  8. configuration 'my-envoy-config.yaml' OK

Envoy logging

By default Envoy system logs are sent to /dev/stderr.

This can be overridden using --log-path.

SystemDocker (Linux Image)Docker (Windows Image)

  1. $ mkdir logs
  2. $ envoy -c envoy-demo.yaml --log-path logs/custom.log
  1. $ mkdir logs
  2. $ chmod go+rwx logs/
  3. $ docker run --rm -it \
  4. -p 10000:10000 \
  5. -v $(pwd)/logs:/logs \
  6. envoyproxy/envoy:v1.22.6 \
  7. -c /etc/envoy/envoy.yaml \
  8. --log-path logs/custom.log
  1. PS> mkdir logs
  2. PS> docker run --rm -it
  3. -p '10000:10000'
  4. -v "$PWD\logs\:`"C:\logs`""
  5. 'envoyproxy/envoy-windows:v1.22.6'
  6. -c 'C:\ProgramData\envoy.yaml'
  7. --log-path 'C:\logs\custom.log'

Note

Envoy on a Windows system Envoy will output to CON by default.

This can also be used as a logging path when configuring logging.

Access log paths can be set for the admin interface, and for configured listeners.

The demo configuration is configured with a listener that logs access to /dev/stdout:

  1. 12 typed_config:
  2. 13 "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
  3. 14 stat_prefix: ingress_http
  4. 15 access_log:
  5. 16 - name: envoy.access_loggers.stdout
  6. 17 typed_config:
  7. 18 "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
  8. 19 http_filters:
  9. 20 - name: envoy.filters.http.router
  10. 21 typed_config:
  11. 22 "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

The default configuration in the Envoy Docker container also logs access in this way.

Logging to /dev/stderr and /dev/stdout for system and access logs respectively can be useful when running Envoy inside a container as the streams can be separated, and logging requires no additional files or directories to be mounted.

Some Envoy filters and extensions may also have additional logging capabilities.

Envoy can be configured to log to different formats, and to different outputs in addition to files and stdout/err.

Envoy networking

By default Envoy can use both IPv4 and IPv6 networks.

If your environment does not support IPv6 you should disable it.

This may be the case when using Docker on a non-linux host (see here for more information regarding IPv6 support in Docker).

You can disable IPv6 by setting the dns_lookup_family to V4_ONLY in your configuration as follows:

envoy-demo.yaml

  1. 34 clusters:
  2. 35 - name: service_envoyproxy_io
  3. 36 type: LOGICAL_DNS
  4. 37 # Comment out the following line to test on v6 networks
  5. 38 dns_lookup_family: V4_ONLY
  6. 39 load_assignment:
  7. 40 cluster_name: service_envoyproxy_io
  8. 41 endpoints:
  9. 42 - lb_endpoints:
  10. 43 - endpoint:
  11. 44 address:
  12. 45 socket_address:

Debugging Envoy

The log level for Envoy system logs can be set using the -l or —log-level option.

The available log levels are:

  • trace

  • debug

  • info

  • warning/warn

  • error

  • critical

  • off

The default is info.

You can also set the log level for specific components using the --component-log-level option.

The following example inhibits all logging except for the upstream and connection components, which are set to debug and trace respectively.

SystemDocker (Linux Image)Docker (Windows Image)

  1. $ envoy -c envoy-demo.yaml -l off --component-log-level upstream:debug,connection:trace
  2. ...
  1. $ docker run --rm -d \
  2. -p 9901:9901 \
  3. -p 10000:10000 \
  4. envoyproxy/envoy:v1.22.6 \
  5. -c /etc/envoy/envoy.yaml \
  6. -l off \
  7. --component-log-level upstream:debug,connection:trace
  8. ...
  1. PS> mkdir logs
  2. PS> docker run --rm -it
  3. -p '10000:10000'
  4. envoyproxy/|envoy_windws_docker_image|
  5. -c 'C:\ProgramData\envoy.yaml'
  6. -l off
  7. --component-log-level 'upstream:debug,connection:trace'
  8. ...

Tip

See ALL_LOGGER_IDS in logger.h for a list of components.