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:

If Envoy is configured with RBAC filter or makes route selection based on URL path it is recommended to enable the following path normalization options to minimize probability of path confusion vulnerabilities. Path confusion vulnerabilities occur when parties participating in request use different path representations.

Additionally the path_with_escaped_slashes_action setting should be set according to following recommendations:

  • REJECT_REQUEST if dowstream clients are expected to use RFC 3986 compliant normalized paths (i.e. gRPC clients).

  • UNESCAPE_AND_REDIRECT if downstream client supports HTTP redirect (i.e. a browser). This option minimizes possibility of path confusion by forcing request to be re-issued with the same path across all parties: downstream client, Envoy and upstream server. Note that gRPC requests will still be rejected with the INTERNAL (13) error code, as gRPC clients do not support redirect.

  • KEEP_UNCHANGED for servers that are not RFC 3986 compliant and require encoded slashes.

  • UNESCAPE_AND_FORWARD for servers that are known to treat escaped and unescaped slashes equivalently. Choosing this option may increase probablity of path confusion vulnerabilities if intermediaries perform path based access control.

The following is a YAML example of the above recommendation (taken from the Google VRP edge server configuration):

  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.extensions.resource_monitors.fixed_heap.v3.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. 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.filters.listener.tls_inspector"
  33. # Uncomment if Envoy is behind a load balancer that exposes client IP address using the PROXY protocol.
  34. # - name: envoy.filters.listener.proxy_protocol
  35. # typed_config:
  36. # "@type": type.googleapis.com/envoy.extensions.filters.listener.proxy_protocol.v3.ProxyProtocol
  37. per_connection_buffer_limit_bytes: 32768 # 32 KiB
  38. filter_chains:
  39. - filter_chain_match:
  40. server_names: ["example.com", "www.example.com"]
  41. transport_socket:
  42. name: envoy.transport_sockets.tls
  43. typed_config:
  44. "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
  45. common_tls_context:
  46. tls_certificates:
  47. - certificate_chain: {filename: "certs/servercert.pem"}
  48. private_key: {filename: "certs/serverkey.pem"}
  49. alpn_protocols: ["h2,http/1.1"]
  50. filters:
  51. - name: envoy.filters.network.http_connection_manager
  52. typed_config:
  53. "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
  54. stat_prefix: ingress_http
  55. use_remote_address: true
  56. normalize_path: true
  57. merge_slashes: true
  58. path_with_escaped_slashes_action: UNESCAPE_AND_REDIRECT
  59. common_http_protocol_options:
  60. idle_timeout: 3600s # 1 hour
  61. headers_with_underscores_action: REJECT_REQUEST
  62. http2_protocol_options:
  63. max_concurrent_streams: 100
  64. initial_stream_window_size: 65536 # 64 KiB
  65. initial_connection_window_size: 1048576 # 1 MiB
  66. stream_idle_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  67. request_timeout: 300s # 5 mins, must be disabled for long-lived and streaming requests
  68. http_filters:
  69. - name: envoy.filters.http.router
  70. route_config:
  71. virtual_hosts:
  72. - name: default
  73. domains: ["*"]
  74. routes:
  75. - match: {prefix: "/"}
  76. route:
  77. cluster: service_foo
  78. idle_timeout: 15s # must be disabled for long-lived and streaming requests
  79. clusters:
  80. - name: service_foo
  81. per_connection_buffer_limit_bytes: 32768 # 32 KiB
  82. load_assignment:
  83. cluster_name: some_service
  84. endpoints:
  85. - lb_endpoints:
  86. - endpoint:
  87. address:
  88. socket_address:
  89. address: 127.0.0.1
  90. port_value: 8080
  91. typed_extension_protocol_options:
  92. envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
  93. "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
  94. explicit_http_config:
  95. http2_protocol_options:
  96. initial_stream_window_size: 65536 # 64 KiB
  97. initial_connection_window_size: 1048576 # 1 MiB
  98. layered_runtime:
  99. layers:
  100. - name: static_layer_0
  101. static_layer:
  102. envoy:
  103. resource_limits:
  104. listener:
  105. example_listener_name:
  106. connection_limit: 10000
  107. overload:
  108. global_downstream_max_connections: 50000