-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Wildcard domain matches before specific domain. #3410
Comments
Thanks for opening an issue! We'll look into this. It's not immediately clear to me what is going on, so I'll need your help to understand it better. Ideally, we need to be able to reproduce the bug in the most minimal way possible. This allows us to write regression tests to verify the fix is working. If we can't reproduce it, then you'll have to test our changes for us until it's fixed -- and then we can't add test cases, either. I've attached a template below that will help make this easier and faster! It will ask for some information you've already provided; that's OK, just fill it out the best you can. 👍 I've also included some helpful tips below the template. Feel free to let me know if you have any questions! Thank you again for your report, we look forward to resolving it! Template
Helpful tips
Example of a tutorial: Create a config file: |
To be clear, I'm asking for more information because your config adapts as expected for me: {
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"specific.example.com"
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"www.example.com",
"*.example.com"
]
}
],
"terminal": true
}
]
}
}
}
}
} |
@mholt The problem isn't that it doesn't adapt - it's that when caddy receives a request on In terms of information: I'm running the latest available (at time of writing) official docker image of caddy. |
We still need more info. Can you give a minimally reproduceable example, with |
Right now this is a "works for me" until we can reproduce it... |
1. Environment1a. Operating system and version
1b. Caddy version (run
|
I'll see if I can prepare a reproducible example. The site in question is live in production, so I can't go back to the "broken" configuration. |
Here's what
Note that the wildcard is part of the group of routes that comes first in the matching array. I'm going to hazard a guess that perhaps this has something to do with the |
Works for me:
|
Closing, since this is working as expected, and there's not currently enough information to reproduce the issue. |
@mholt I posted the broken configuration just before you closed this, so you may have missed it. I may be able to switch to the broken configuration briefly tonight to have a reproducible test case. |
@pnomolos Indeed, thanks. But, there's still not enough information here. The adapted config appears to be working as shown. Please, why won't you fill out the template? |
@mholt Sorry, but what's missing from the template that I haven't provided? I've given the caddy version and OS information, the configuration, and what's not working. I don't have any further information to post, as far as I can tell. |
@pnomolos I don't know if this was intentional, but you literally only filled out half of it: Using the Caddyfile you gave me above (the only other piece of information), I was not able to reproduce the problem you're describing. Just please please please please please please please please please please please please please please please please fill out the issue template? |
1. Environment1a. Operating system and version
1b. Caddy version (run
|
Alright, I was able to confirm the bug:
Will order the sites in the wrong order:
If I remove
The reason for this is the logic here: caddy/caddyconfig/httpcaddyfile/httptype.go Line 357 in ea7e4b4
It's comparing the string lengths of the sites, and It probably needs to be adjusted to force a slice that contains a |
FYI as a hotfix, I recommend moving the For example:
Will sort like this:
|
@francislavoie Thanks! Glad to know I'm not completely crazy and there was something going on :) |
Caddyfile like so:
A request to
specific.example.com
will get routed to the second definition. My hope was to use it as a catch-all for mis-spellings, etc.The text was updated successfully, but these errors were encountered: