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