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