Fix app-root with query params redirect

This commit is contained in:
LBF38 2026-04-16 10:40:10 +02:00 committed by GitHub
parent 2b9ffc4261
commit 4b678ce9fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View File

@ -715,7 +715,7 @@ type RedirectScheme struct {
Permanent bool `json:"permanent,omitempty" toml:"permanent,omitempty" yaml:"permanent,omitempty" export:"true"`
// ForcePermanentRedirect is an internal field (not exposed in configuration).
// When set to true, this forces the use of permanent redirects 308, regardless of the request method.
// Used by the provider ingress-ngin.
// Used by the provider ingress-nginx.
ForcePermanentRedirect bool `json:"-" toml:"-" yaml:"-" label:"-" file:"-" kv:"-" export:"true"`
}

View File

@ -1675,7 +1675,7 @@ func applyAppRootConfiguration(routerName string, ingressConfig IngressConfig, r
appRootMiddlewareName := routerName + "-app-root"
conf.HTTP.Middlewares[appRootMiddlewareName] = &dynamic.Middleware{
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1" + *ingressConfig.AppRoot,
},
}

View File

@ -3859,13 +3859,13 @@ func TestLoadIngresses(t *testing.T) {
Middlewares: map[string]*dynamic.Middleware{
"default-ingress-with-app-root-rule-0-path-0-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-app-root-rule-0-path-0-tls-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
@ -11528,25 +11528,25 @@ func TestLoadIngresses(t *testing.T) {
Middlewares: map[string]*dynamic.Middleware{
"default-ingress-with-canary-middlewares-rule-0-path-0-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-canary-middlewares-rule-0-path-0-tls-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-canary-middlewares-rule-0-path-0-canary-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-canary-middlewares-rule-0-path-0-canary-tls-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
@ -11828,13 +11828,13 @@ func TestLoadIngresses(t *testing.T) {
Middlewares: map[string]*dynamic.Middleware{
"default-ingress-with-canary-middlewares-and-tls-rule-0-path-0-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-canary-middlewares-and-tls-rule-0-path-0-tls-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
@ -11850,13 +11850,13 @@ func TestLoadIngresses(t *testing.T) {
},
"default-ingress-with-canary-middlewares-and-tls-rule-0-path-0-canary-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},
"default-ingress-with-canary-middlewares-and-tls-rule-0-path-0-canary-tls-app-root": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: `^(https?://[^/]+)/$`,
Regex: `^(https?://[^/]+)/(\?.*)?$`,
Replacement: "$1/foo",
},
},