envoy listener 2 ports + 2 clusters

1.6k views Asked by At

I try to set 2 listener in config with different ports and clusters for redirect

    static_resources:
  listeners:
  - name: listener_back_end
    address:
      socket_address: { address: 0.0.0.0, port_value: 9090 }
    filter_chains:
    - filters:
      - name: envoy.tcp_proxy
        config:
          stat_prefix: ingress_tcp
          cluster: back_end
      tls_context:
        common_tls_context:
          tls_certificates:
            - certificate_chain:
                filename: "/ProxyServerConfig/SSL/certificate.crt"
              private_key:
                filename: "/ProxyServerConfig/SSL/private.key"
  clusters:
  - name: back_end
    connect_timeout: 0.2s
    type: STATIC
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: 192.168.1.4, port_value: 1990 
}}]
  - name: listener_front_end
    address:
      socket_address: { address: 0.0.0.0, port_value: 443 }
    filter_chains:
    - filters:
      - name: envoy.tcp_proxy
        config:
          stat_prefix: ingress_tcp
          cluster: front_end
      tls_context:
        common_tls_context:
          tls_certificates:
            - certificate_chain:
                filename: "/ProxyServerConfig/SSL/certificate.crt"
              private_key:
                filename: "/ProxyServerConfig/SSL/private.key"
  clusters:
  - name: front_end
    connect_timeout: 0.2s
    type: STATIC
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: 192.168.1.5, port_value: 8081 
}}]

envoy is started but when I try open in browser any of this port I get: ERR_CONNECTION_CLOSED. Each configuration works separately...

Anyone can help? Thanks!

1

There are 1 answers

0
Alejandro On

try moving the listener out of the cluster configuration. Move your listeners together, and your clusters together.

   static_resources:
  listeners:
  - name: listener_back_end
    address:
      socket_address: { address: 0.0.0.0, port_value: 9090 }
    filter_chains:
    - filters:
      - name: envoy.tcp_proxy
        config:
          stat_prefix: ingress_tcp
          cluster: back_end
      tls_context:
        common_tls_context:
          tls_certificates:
            - certificate_chain:
                filename: "/ProxyServerConfig/SSL/certificate.crt"
              private_key:
                filename: "/ProxyServerConfig/SSL/private.key"
  - name: listener_front_end
    address:
      socket_address: { address: 0.0.0.0, port_value: 443 }
    filter_chains:
    - filters:
      - name: envoy.tcp_proxy
        config:
          stat_prefix: ingress_tcp
          cluster: front_end
      tls_context:
        common_tls_context:
          tls_certificates:
            - certificate_chain:
                filename: "/ProxyServerConfig/SSL/certificate.crt"
              private_key:
                filename: "/ProxyServerConfig/SSL/private.key"
  clusters:
  - name: back_end
    connect_timeout: 0.2s
    type: STATIC
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: 192.168.1.4, port_value: 1990 
  - name: front_end
    connect_timeout: 0.2s
    type: STATIC
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: 192.168.1.5, port_value: 8081 
}}]