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.filters.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.filters.network.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. headers_with_underscores_action: REJECT_REQUEST
  55. http2_protocol_options:
  56. max_concurrent_streams: 100
  57. initial_stream_window_size: 65536 # 64 KiB
  58. initial_connection_window_size: 1048576 # 1 MiB
  59. stream_idle_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  60. request_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  61. route_config:
  62. virtual_hosts:
  63. - name: default
  64. domains: "*"
  65. routes:
  66. - match: { prefix: "/" }
  67. route:
  68. cluster: service_foo
  69. idle_timeout: 15s # must be disabled for long-lived and streaming requests
  70. clusters:
  71. name: service_foo
  72. connect_timeout: 15s
  73. per_connection_buffer_limit_bytes: 32768 # 32 KiB
  74. hosts:
  75. socket_address:
  76. address: 127.0.0.1
  77. port_value: 8080
  78. http2_protocol_options:
  79. initial_stream_window_size: 65536 # 64 KiB
  80. initial_connection_window_size: 1048576 # 1 MiB