envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Unable to make http GET request for filter - envoy.filters.network.http_connection_manager

Open SunilDSK opened this issue 1 year ago • 2 comments

Title: Unable to make http GET request for filter - envoy.filters.network.http_connection_manager. Using it to add /health endpoint with direct_response

Description: Hi there, I am new to envoy. I am using envoy as redis_proxy to expose my valkey instances. below is my envoy config.

static_resources:
  listeners:
  - name: valkey_listener
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 6389
    filter_chains:
    # Filter chain for HTTP traffic
    - filter_chain_match:
        application_protocols: ["http/1.1", "h2"]
      filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
              - name: backend
                domains:
                  - "*"
                routes:
                  - match:  
                      path: "/health"  
                    direct_response:  
                      status: 200  
                      body:  
                        inline_string: 'healthy'
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

    # Filter chain for Redis traffic
    default_filter_chain:
      filters:
      - name: envoy.filters.network.redis_proxy
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.redis_proxy.v3.RedisProxy
          stat_prefix: egress_valkey
          settings:
            op_timeout: 1s
            enable_hashtagging: true
            enable_redirection: false
            enable_command_stats: false
          prefix_routes:
            catch_all_route:
              cluster: valkey_standalone
          downstream_auth_passwords:
            inline_string: "worker"
          downstream_auth_username: 
            inline_string: "worker"
    

  clusters:
  - name: valkey_standalone
    type: STRICT_DNS
    dns_lookup_family: V4_ONLY
    connect_timeout: 10s
    lb_policy: RING_HASH
    load_assignment:
      cluster_name: valkey_standalone
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: valkey-service.may-namespace.svc.cluster.local
                port_value: 6389
    typed_extension_protocol_options:
      envoy.filters.network.redis_proxy:
        "@type": type.googleapis.com/google.protobuf.Struct
        value:
          auth_password:
            inline_string: "worker"
          auth_username:
            inline_string: "worker"
admin:
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 8080

Requirements:

  • I am trying to expose a health endpoint on the same port as valkey_listener listener - 6389. So when I make a curl request - curl http://<<envoy_server>>:6389/health, I am expecting a HTTP response 200 with string healthy. I am trying to add envoy in a LoadBalancer and the LoadBalancer need a health probe.
    • Currently when I make the curl request with the above configurations I am getting the below error -
      curl -v http://<<envoy_server>>:6389/health
      *   Trying <<envoy_server>>:6389...
      * Connected to <<envoy_server>> (<<envoy_server>>) port 6389
      > GET /health HTTP/1.1
      > Host: <<envoy_server>>:6389
      > User-Agent: curl/8.8.0
      > Accept: */*
      >
      * Request completely sent off
      * Received HTTP/0.9 when not allowed
      * Closing connection
      curl: (1) Received HTTP/0.9 when not allowed
    
  • The above configuration is working for redis/valkey connection and I am able to use the valkey instances successfully but unable to add a health endpoint on the same listener.
  • Also, please helm me add a logging for both filters -
    • envoy.filters.network.http_connection_manager
    • envoy.filters.network.redis_proxy

[Links I referred:]

SunilDSK avatar Apr 03 '25 18:04 SunilDSK

Using application_protocols filter chain matcher requires TLS transport for downstream connections or the https://www.envoyproxy.io/docs/envoy/latest/configuration/listeners/listener_filters/http_inspector listener filter. As configured it will never work, the redis filter chain will always be selected.

You can try adding the http_inspector listener filter and see if it solves your problem.

yanavlasov avatar Apr 04 '25 18:04 yanavlasov

Thank you verymuch @yanavlasov. This worked for me.

SunilDSK avatar Apr 21 '25 16:04 SunilDSK