Configuring Envoy as an edge proxy

Envoy is a production-ready edge proxy, however, the default settings are tailored for the service mesh use case, and some values need to be adjusted when using Envoy as an edge proxy.

TCP proxies should configure:

HTTP proxies should additionally configure:

The following is a YAML example of the above recommendation.

  1. overload_manager:
  2. refresh_interval: 0.25s
  3. resource_monitors:
  4. - name: "envoy.resource_monitors.fixed_heap"
  5. config:
  6. # TODO: Tune for your system.
  7. max_heap_size_bytes: 2147483648 # 2 GiB
  8. actions:
  9. - name: "envoy.overload_actions.shrink_heap"
  10. triggers:
  11. - name: "envoy.resource_monitors.fixed_heap"
  12. threshold:
  13. value: 0.95
  14. - name: "envoy.overload_actions.stop_accepting_requests"
  15. triggers:
  16. - name: "envoy.resource_monitors.fixed_heap"
  17. threshold:
  18. value: 0.98
  19. admin:
  20. access_log_path: "/var/log/envoy_admin.log"
  21. address:
  22. socket_address:
  23. address: 127.0.0.1
  24. port_value: 9090
  25. static_resources:
  26. listeners:
  27. - address:
  28. socket_address:
  29. address: 0.0.0.0
  30. port_value: 443
  31. listener_filters:
  32. - name: "envoy.listener.tls_inspector"
  33. typed_config: {}
  34. per_connection_buffer_limit_bytes: 32768 # 32 KiB
  35. filter_chains:
  36. - filter_chain_match:
  37. server_names: ["example.com", "www.example.com"]
  38. tls_context:
  39. common_tls_context:
  40. tls_certificates:
  41. - certificate_chain: { filename: "example_com_cert.pem" }
  42. private_key: { filename: "example_com_key.pem" }
  43. filters:
  44. - name: envoy.http_connection_manager
  45. typed_config:
  46. "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
  47. stat_prefix: ingress_http
  48. use_remote_address: true
  49. # Uncomment if Envoy is behind a load balancer that exposes client IP address using the PROXY protocol.
  50. # use_proxy_proto: true
  51. common_http_protocol_options:
  52. idle_timeout: 3600s # 1 hour
  53. http2_protocol_options:
  54. max_concurrent_streams: 100
  55. initial_stream_window_size: 65536 # 64 KiB
  56. initial_connection_window_size: 1048576 # 1 MiB
  57. stream_idle_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  58. request_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  59. route_config:
  60. virtual_hosts:
  61. - name: default
  62. domains: "*"
  63. routes:
  64. - match: { prefix: "/" }
  65. route:
  66. cluster: service_foo
  67. idle_timeout: 15s # must be disabled for long-lived and streaming requests
  68. clusters:
  69. name: service_foo
  70. connect_timeout: 15s
  71. per_connection_buffer_limit_bytes: 32768 # 32 KiB
  72. hosts:
  73. socket_address:
  74. address: 127.0.0.1
  75. port_value: 8080
  76. http2_protocol_options:
  77. initial_stream_window_size: 65536 # 64 KiB
  78. initial_connection_window_size: 1048576 # 1 MiB