Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route fails to match if host header contains a port domains omits port #3515

Closed
taion809 opened this issue May 31, 2018 · 2 comments
Closed

Comments

@taion809
Copy link
Contributor

Title: Route fails to match if host header contains a port but domains omits port

Description:
Port numbers in an http host header affect route matching in envoy in a way that is unexpected as a user. When issuing an http request, as a user, I would expect curl service:80 to be matched as if I had issued the following request curl service. What happens now is that if the list of domains in a virtual host does not contain both the domain with and without a port it will not be matched and return a 404.

Configuration

admin:
  access_log_path: /tmp/admin_access.log
  address:
    socket_address: { address: 127.0.0.1, port_value: 9901 }

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0, port_value: 80 }
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["envoy.localhost"]
              routes:
              - match: { prefix: "/" }
                route: { host_rewrite: www.google.com, cluster: service_google }
          http_filters:
          - name: envoy.router
  clusters:
  - name: service_google
    connect_timeout: 0.25s
    type: LOGICAL_DNS
    # Comment out the following line to test on v6 networks
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: google.com, port_value: 443 }}]
    tls_context: { sni: www.google.com }

Repro steps:
Success:

curl -v envoy.localhost:80

Failure:

curl -v envoy.localhost:80 -H 'Host: envoy.localhost:80'

The reason this succeeds is that curl will drop the port number from the host header when it is a well-known port like port 80. This is not consistent across all http clients of course, prometheus for example may issue a scrape request with the host header set to include a port number.

I understand this is not necessarily a bug but it does break with existing proxies and existing expectations.

@taion809 taion809 changed the title Route fails to match if host header contains a port Route fails to match if host header contains a port domains omits port May 31, 2018
@mattklein123
Copy link
Member

@taion809 this is a duplicate of #886 I think? Are you OK with tracking in that issue?

@taion809
Copy link
Contributor Author

ah cool sorry, i actually searched the issues first before posting so I must have missed that 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants