SNI dynamic forward proxy

Attention

SNI dynamic forward proxy support should be considered alpha and not production ready.

Through the combination of TLS inspector listener filter, this network filter and the dynamic forward proxy cluster, Envoy supports SNI based dynamic forward proxy. The implementation works just like the HTTP dynamic forward proxy, but using the value in SNI as target host instead.

The following is a complete configuration that configures both this filter as well as the dynamic forward proxy cluster. Both filter and cluster must be configured together and point to the same DNS cache parameters for Envoy to operate as an SNI dynamic forward proxy.

Note

The following config doesn’t terminate TLS in listener, so there is no need to configure TLS context in cluster. The TLS handshake is passed through by Envoy.

  1. admin:
  2. address:
  3. socket_address:
  4. protocol: TCP
  5. address: 127.0.0.1
  6. port_value: 9901
  7. static_resources:
  8. listeners:
  9. - name: listener_0
  10. address:
  11. socket_address:
  12. protocol: TCP
  13. address: 0.0.0.0
  14. port_value: 10000
  15. listener_filters:
  16. - name: envoy.filters.listener.tls_inspector
  17. filter_chains:
  18. - filters:
  19. - name: envoy.filters.network.sni_dynamic_forward_proxy
  20. typed_config:
  21. "@type": type.googleapis.com/envoy.extensions.filters.network.sni_dynamic_forward_proxy.v3.FilterConfig
  22. port_value: 443
  23. dns_cache_config:
  24. name: dynamic_forward_proxy_cache_config
  25. dns_lookup_family: V4_ONLY
  26. - name: envoy.tcp_proxy
  27. typed_config:
  28. "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
  29. stat_prefix: tcp
  30. cluster: dynamic_forward_proxy_cluster
  31. clusters:
  32. - name: dynamic_forward_proxy_cluster
  33. lb_policy: CLUSTER_PROVIDED
  34. cluster_type:
  35. name: envoy.clusters.dynamic_forward_proxy
  36. typed_config:
  37. "@type": type.googleapis.com/envoy.extensions.clusters.dynamic_forward_proxy.v3.ClusterConfig
  38. dns_cache_config:
  39. name: dynamic_forward_proxy_cache_config
  40. dns_lookup_family: V4_ONLY