envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
25.12k stars 4.82k forks source link

envoy.filters.http.dynamic_forward_proxy can it support host_rewrite_regex in addition to host_rewrite_literal #24214

Open MyCADDev opened 2 years ago

MyCADDev commented 2 years ago

I want to rewrite the route like this and lookup DNS

http://example.com/guid/getstuff

http://guid.example.internal/guid/getstuff

So can something like this be supported - host_rewrite_regex instead of host_rewrite_literal which is currently supported

          typed_per_filter_config:
            envoy.filters.http.dynamic_forward_proxy:
              "@type": type.googleapis.com/envoy.extensions.filters.http.dynamic_forward_proxy.v3.PerRouteConfig
              host_rewrite_regex:
                pattern:
                  regex: "^/(.+)/(.+$)"
                substitution: \1.example.internal

The full listener

    - name: listener_1
      address:
        socket_address: { address: 0.0.0.0, port_value: 8080 }
      filter_chains:
        - filters:
            - name: envoy.filters.network.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                generate_request_id: true
                codec_type: auto
                stat_prefix: ingress_http
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: local_service
                      domains: ["*"]
                      routes:
                        - match: { prefix: "/" }
                          route:
                            host_rewrite_path_regex:
                              pattern:
                                regex: "^/(.+)/(.+$)"
                              substitution: \1.example.internal
                            append_x_forwarded_host: true
                            cluster: example_dns
                          typed_per_filter_config:
                            envoy.filters.http.dynamic_forward_proxy:
                              "@type": type.googleapis.com/envoy.extensions.filters.http.dynamic_forward_proxy.v3.PerRouteConfig
                              host_rewrite_regex:
                                pattern:
                                  regex: "^/(.+)/(.+$)"
                                substitution: \1.example.internal
                http_filters:
                - name: envoy.filters.http.dynamic_forward_proxy
                  typed_config:
                    "@type": type.googleapis.com/envoy.extensions.filters.http.dynamic_forward_proxy.v3.FilterConfig
                    dns_cache_config:
                      name: dynamic_forward_proxy_cache_config
                      dns_lookup_family: V4_ONLY
                      typed_dns_resolver_config:
                        name: envoy.network.dns_resolver.cares
                        typed_config:
                          "@type": type.googleapis.com/envoy.extensions.network.dns_resolver.cares.v3.CaresDnsResolverConfig
                          resolvers:
                            - socket_address:
                                address: "172.16.238.10"
                                port_value: 53
                          dns_resolver_options:
                            use_tcp_for_dns_lookups: true
                            no_default_search_domain: true
                - name: envoy.filters.http.router
                  typed_config:
                    "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
wbpcode commented 2 years ago

cc @alyssawilk

pxpnetworks commented 1 year ago

Hello, host_rewrite_regex with dfp will also be very useful in my forward proxy installations :)

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

supercairos commented 1 month ago

I would love to this feature happening :)