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

Please add support for wildcard virtual hosts #1228

Closed
yarivlifchuk opened this issue Jul 7, 2019 · 35 comments · Fixed by #4145
Closed

Please add support for wildcard virtual hosts #1228

yarivlifchuk opened this issue Jul 7, 2019 · 35 comments · Fixed by #4145
Assignees
Labels
area/httpproxy Issues or PRs related to the HTTPProxy API. kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@yarivlifchuk
Copy link

Hi,

I need multiple virtual host fqdn routed to the same backend service, example:
devxnew-workspaces-ws-8zdgz.istio-wing.dev1.sapwebide.net.sap
devxnew-workspaces-ws-8zdgz-app1.istio-wing.dev1.sapwebide.net.sap
devxnew-workspaces-ws-8zdgz-app2.istio-wing.dev1.sapwebide.net.sap
devxnew-workspaces-ws-8zdgz-app3.istio-wing.dev1.sapwebide.net.sap
devxnew-workspaces-ws-8zdgz-app4.istio-wing.dev1.sapwebide.net.sap
devxnew-workspaces-ws-8zdgz-app5.istio-wing.dev1.webide.net.sap

These virtual host should be replaced with one
devxnew-workspaces-ws-8zdgz*.istio-wing.dev1.webide.net.sap

Describe the solution you'd like
virtual host fqdn support regexp
example: aaa*.dev.one.com

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Contour version:
  • Kubernetes version: (use kubectl version):
  • Kubernetes installer & version:
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
@davecheney
Copy link
Contributor

davecheney commented Jul 9, 2019 via email

@yarivlifchuk
Copy link
Author

yarivlifchuk commented Jul 9, 2019 via email

@stevesloka
Copy link
Member

Thanks for the feedback @yarivlifchuk, I'm working on a design proposal (which I'll have soon) to revamp what Contour allows users to route on and with. This is super helpful to drive that design. I'll post back when I have the design ready.

@stevesloka stevesloka added kind/feature Categorizes issue or PR as related to a new feature. ingressroutev1 labels Jul 11, 2019
@davecheney davecheney changed the title Virtual host Please add support for wildcard virtual hosts Sep 29, 2019
@davecheney davecheney added this to the Backlog milestone Sep 29, 2019
@davecheney davecheney added the blocked/needs-product Categorizes the issue or PR as blocked because it needs a decision from product management. label Sep 29, 2019
@chen-anders
Copy link

In our case, we'd need support for something like *.example.com .

@bgagnon
Copy link
Contributor

bgagnon commented Oct 25, 2019

Is there a technical difference between this feature and having multiple HTTProxy/IngressRoutes with different fqdns and a delegation to a common one? Is it for cases where the fqdn values are numerous, or not registerable in the control plane?

@chen-anders
Copy link

One example use-case that I'm targeting here (that we currently use nginx-ingress for) is that we have 65,000+ customers that have some <username-derived-subdomain>.example.com as part of how one of our legacy main applications work. It would seem untenable to have to enumerate each one in the HTTProxy rules.

@bgagnon
Copy link
Contributor

bgagnon commented Oct 25, 2019

Thanks for clearing that up @chen-anders !

@davidhole
Copy link

davidhole commented Jun 10, 2020

@bgagnon We have the same use-case as @chen-anders... Thousands of subdomains which are served that way for vanity URL purposes... business-name.ourdomain.com

Currently using nginx-ingress to handle this, but wanting to move to contour for many many reasons...

This would be a fantastic addition. Thanks for your time and efforts!

@jpeach
Copy link
Contributor

jpeach commented Jun 10, 2020

xref #2138

@mspinassi
Copy link

+1

@xaleeks
Copy link

xaleeks commented Feb 3, 2021

This is pretty important, but always leaves some room for a potential disaster. We should put some thought into design here, although it feels fairly basic.

@youngnick
Copy link
Member

The service-apis defines a "wildcard" hostname as one that contains a * for the whole first label of the hostname. (This is "globbing" in Dave's questions above.) Implementing only that would be much easier than a more complex scheme, and would get us a fair chunk of this functionality.

We have #2138 which covers implementing this for Ingress V1 - the service-apis wildcard match is the same. I'd suggest that we implement #2138, and then follow up here and see how many people's needs that can fill.

@xaleeks
Copy link

xaleeks commented Feb 5, 2021

sounds good, we'll leave it out of v1.13

Thought of something else which is what if I wanted a regex to cover a large number of domains except for a particular one that should go to a different service. Would we need to introduce some notion of priority when there are multiple matches. Or are we implementing full blown regex, like support negative look ahead etc

@youngnick
Copy link
Member

We could conceivably implement full regex for fqdn, but that's difficult verging on impossible to reconcile with SNI matching based on hostname. In order to ensure that things match on hostname properly, we need to order the hostnames in most-specific to least-specific order, and with full regex support, that order is not really defined.

In short, globbing a whole DNS label is achievable, after that, the more clever we get, the harder it is to make it work as you would expect. ( A DNS label is any part of a hostname between periods.)

You can use the basic globbing support to do a large number of domains with exceptions, but the exceptions will need to be precise matches (that is, have no wildcards in them). This is again because when you go smaller than a single label, it's difficult to order the rules from most- to least-specific.

Effectively, the most-specific to least-specific ordering is priority for matches, and we avoid needing to have some out-of-band priority by mandating globbing only at the DNS label level.

@sunjayBhatia
Copy link
Member

sunjayBhatia commented Feb 10, 2021

sounds good, we'll leave it out of v1.13

Thought of something else which is what if I wanted a regex to cover a large number of domains except for a particular one that should go to a different service. Would we need to introduce some notion of priority when there are multiple matches. Or are we implementing full blown regex, like support negative look ahead etc

I was going to say, should I pick this up, but then again seeing this comment and the others, maybe not

Should it be pulled out of the prioritized backlog and pull in #2138 instead? Ah I see the 1.13 board is the one to pull from, disregard this

@kevinlmadison
Copy link

Hey guys, wondering what the status on this is? This would be an amazingly helpful addition.

@sunjayBhatia
Copy link
Member

sunjayBhatia commented Apr 20, 2021

We are adding support for wildcard hosts as part of Ingress v1 support: #3381

Gateway API objects will also support wildcard hosts as per the spec: https://gateway-api.sigs.k8s.io/references/spec/#networking.x-k8s.io/v1alpha1.Listener (and other resources)

@amdonov
Copy link

amdonov commented May 27, 2021

While it's great to have wildcard support on ingress and gateway resources, it would still be helpful to have on HTTPProxy. Please correct me if I'm wrong. I can't figure out how to do TLS passthrough with ingress. Gateway isn't ideal for us because it is so new and forces use of the operator. We're using some options with the helm chart such as node selectors, tolerations, and hostNetwork that the operator doesn't support. In addition, the specification doesn't seem to support/address proxy-protocol. We'd love to continue with our current deployment approach and use HTTPProxy for passthrough and proxy-protocol support where needed, but we really need glob matching. Nothing fancy just what's required for gateway.

@youngnick
Copy link
Member

Thanks @amdonov. So you just want to be able to do the same first-label-only wildcard match that we do for Gateway? We may be able to port that functionality to HTTPProxy if that's all that's required (since we've already figured out how to do it for Gateway).

@artificial-aidan
Copy link
Contributor

+1 on this. We require HTTPProxy for client cert authentication, but also use wildcard domain matching.

@youngnick
Copy link
Member

Thanks for that @artificial-aidan. Would the same first-label-only wildcard match work for you?

@artificial-aidan
Copy link
Contributor

I believe it would. As long as first-label-only works with multiple trailing domains, i.e. *.sub.example.com

@youngnick
Copy link
Member

Awesome. Yes, first-label-only just means that only the first label, up to the period, can be replaced.

So *.sub.example.com would match foo.sub.example.com and bar.sub.example.com, but not foo.bar.sub.example.com.

@artificial-aidan
Copy link
Contributor

Awesome. I'll stay subscribed to this.

@youngnick youngnick removed the blocked/needs-product Categorizes the issue or PR as blocked because it needs a decision from product management. label Aug 26, 2021
@youngnick
Copy link
Member

Okay, so the TODO for this issue is this;

  • take the first-label wildcard semantics that we have for Ingress and Gateway API, and apply it to HTTPProxy's spec.virtualhost.fqdn field.
  • The rules about root HTTPProxy objects should be largely unchanged, since *.bar.com and foo.bar.com are separate hostnames, and so can have separate HTTPProxy root objects.

This issue is ready to be picked up.

@xaleeks
Copy link

xaleeks commented Aug 31, 2021

Do we have capacity to pick this up in 1.20. Or shall we move it to 1.21

@artificial-aidan
Copy link
Contributor

What is the size of it? Are the HTTPProxy and Gateway API objects similar? If its mostly copy paste I may have some bandwidth to contribute.

@xaleeks
Copy link

xaleeks commented Aug 31, 2021

Thanks for wanting to contribute to this. Maybe @sunjayBhatia can give some guidance

@sunjayBhatia
Copy link
Member

should be a somewhat straightforward change, the main thing is adding the appropriate unit and end-to-end tests

@youngnick
Copy link
Member

Yes, I think a fair bit will be copy-and-paste or reusing helpers from Ingress/Gateway API code. And I agree that the main thing is adding the tests, some of the tests for the DAG in particular are way too big (it's on the list).

If you would like to take this one @artificial-aidan, please feel free, and hit up the Slack channel if you need help with shepherding.

@youngnick youngnick modified the milestones: Backlog, 1.20.0 Sep 22, 2021
@stevesloka
Copy link
Member

@artificial-aidan were you still interested in picking this up? If not I can take it. =)

@artificial-aidan
Copy link
Contributor

Been pretty busy lately. Go for it. If I get some free time I'll reach out to see if you need help in anyway.

@stevesloka stevesloka self-assigned this Oct 21, 2021
@stevesloka stevesloka moved this to Todo in Contour Oct 26, 2021
@stevesloka stevesloka moved this from Todo to In Progress in Contour Oct 26, 2021
stevesloka added a commit to stevesloka/contour that referenced this issue Oct 29, 2021
stevesloka added a commit that referenced this issue Nov 1, 2021
Repository owner moved this from In Progress to Done in Contour Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/httpproxy Issues or PRs related to the HTTPProxy API. kind/feature Categorizes issue or PR as related to a new feature.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.