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

Better handling for domain matching with ports #886

Closed
robertfreund opened this issue May 3, 2017 · 10 comments · Fixed by #10960
Closed

Better handling for domain matching with ports #886

robertfreund opened this issue May 3, 2017 · 10 comments · Fixed by #10960
Labels
area/http enhancement Feature requests. Not bugs or questions. help wanted Needs help!
Milestone

Comments

@robertfreund
Copy link

When explicitly adding port 80 to host such as http://host:80 it will not allow a redirect to https://host:443.

require_ssl of the virtualHost will redirect to https://host:80. What is desired is a redirect to https://host:443 when :80 is explicit.

@mattklein123 mattklein123 added the enhancement Feature requests. Not bugs or questions. label May 3, 2017
@mattklein123
Copy link
Member

I'm not completely clear on the right behaviors here per RFCs. Needs some research. This would be a good opportunity to generally look at how we handle port inside the host/authority header.

@m11y
Copy link

m11y commented Feb 7, 2018

example.com:443 and example.com should be the same virtual host, but currently, gRPC requests with port in authority got 404.

It will be great if envoy strip the standard port portion(like 443, or 80), then do domain match to decide which virtual host a request should go.

@mattklein123 mattklein123 changed the title When port 80 is explicit require_ssl does not allow port override to 443 Better handling for domain matching with ports Jun 25, 2018
@swift1911
Copy link

any progress this issue?

@jeteon
Copy link

jeteon commented Mar 19, 2019

A workaround that seems to work is to explicitly match on both a version with and without the port.

This was quite surprising to find. In my case I struggled to see why Prometheus scrape requests failed with 404s when browser (and almost everything else) checks on the same URL worked just fine. It was only when I discovered that it added the port to the domain that I found this issue.

@bitsofinfo
Copy link

Anyone have a workaround for Envoy based gateways configurable via kubernetes Ingress configs which gives the following if you try to qualify w/ port which is not permitted?

The Ingress "my-ingress" is invalid: spec.rules[0].host: Invalid value: "my-app.local:30443": a DNS-1123 subdomain must consist o
f lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a
-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

@An0nymous0
Copy link

Has this thing progressed?

@zuercher
Copy link
Member

@bitsofinfo if the envoy virtual host were configured with domains: [ "host", "host:*" ] it will allow any port, including a port that was elided as the default port for the scheme.

@migumun
Copy link

migumun commented Sep 10, 2019

Is there any progress on this? I'm also facing the issue (ended up here from istio/istio#8807)

@gnz00
Copy link

gnz00 commented Sep 15, 2019 via email

@greenenergy
Copy link

greenenergy commented Oct 23, 2019

I too am having issues with this, but I have another bit of info to add. I'm using istio, and trying to create Virtual Service & Gateway entries for both http and https services. The https service I have does its own TLS termination, so I'm using a TLS PASSTHROUGH. The istioingressgateway listens on port 31380 for http and 31390 for https. I am using happy.localdomain for the TLS service that works, and sad.localdomain for the http service that does not.

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: happy-gw
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: PASSTHROUGH
    hosts:
    - happy.localdomain

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: happy-vs
spec:
  hosts:
  - happy.localdomain
  gateways:
  - happy-gw
  tls:
  - match:
    - port: 443
      sni_hosts:
      - happy.localdomain
    route:
    - destination:
        host: happy-svc
        port:
          number: 8443

This works perfectly. Requests going to https://happy.localdomain:31390 get sent correctly to port 8443 of happy-svc.

But this does not work:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: sad-gw
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "sad.localdomain"

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sad-vs
spec:
  hosts:
  - "sad.localdomain"
  gateways:
  - sad-gw
  http:
    - destination:
        port:
          number: 8080
        host: sad-svc

Requests to http://sad.localdomain:31380 return 404.

$ curl -vvv http://sad.localdomain:31380
* Rebuilt URL to: http://sad.localdomain:31380/
*   Trying 192.168.99.100...
* Connected to sad.localdomain (192.168.99.100) port 31380 (#0)
> GET / HTTP/1.1
> Host: sad.localdomain:31380
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< date: Wed, 23 Oct 2019 22:15:43 GMT
< server: istio-envoy
< content-length: 0
< 
* Connection #0 to host sad.localdomain left intact

Why does it work for TLS connections but not HTTP?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/http enhancement Feature requests. Not bugs or questions. help wanted Needs help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.