1
0
mirror of https://github.com/containous/traefik.git synced 2025-03-11 16:58:23 +03:00

Fix models mechanism for default rule syntax

Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
Romain 2024-11-29 10:52:05 +01:00 committed by GitHub
parent 536e11d949
commit 2b35c7e205
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 11 deletions

View File

@ -223,6 +223,12 @@ func (i *Provider) entryPointModels(cfg *dynamic.Configuration) {
}
for name, ep := range i.staticCfg.EntryPoints {
if defaultRuleSyntax != "" {
cfg.TCP.Models[name] = &dynamic.TCPModel{
DefaultRuleSyntax: defaultRuleSyntax,
}
}
if len(ep.HTTP.Middlewares) == 0 && ep.HTTP.TLS == nil && defaultRuleSyntax == "" {
continue
}
@ -242,16 +248,6 @@ func (i *Provider) entryPointModels(cfg *dynamic.Configuration) {
m.DefaultRuleSyntax = defaultRuleSyntax
cfg.HTTP.Models[name] = m
if cfg.TCP == nil {
continue
}
mTCP := &dynamic.TCPModel{
DefaultRuleSyntax: defaultRuleSyntax,
}
cfg.TCP.Models[name] = mTCP
}
}

View File

@ -2,6 +2,7 @@ package server
import (
"slices"
"strings"
"github.com/go-acme/lego/v4/challenge/tlsalpn01"
"github.com/rs/zerolog/log"
@ -156,7 +157,11 @@ func applyModel(cfg dynamic.Configuration) dynamic.Configuration {
router := rt.DeepCopy()
if !router.DefaultRule && router.RuleSyntax == "" {
for _, model := range cfg.HTTP.Models {
for modelName, model := range cfg.HTTP.Models {
// models cannot be provided by another provider than the internal one.
if !strings.HasSuffix(modelName, "@internal") {
continue
}
router.RuleSyntax = model.DefaultRuleSyntax
break
}