Redirect for app-root should preserve current scheme (#5266)
This commit is contained in:
parent
84619d7b08
commit
07b70f68bd
4 changed files with 67 additions and 18 deletions
|
|
@ -17,9 +17,13 @@ limitations under the License.
|
|||
package rewrite
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
networking "k8s.io/api/networking/v1beta1"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/errors"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
)
|
||||
|
||||
|
|
@ -90,8 +94,29 @@ func (a rewrite) Parse(ing *networking.Ingress) (interface{}, error) {
|
|||
config.ForceSSLRedirect = a.r.GetDefaultBackend().ForceSSLRedirect
|
||||
}
|
||||
|
||||
config.AppRoot, _ = parser.GetStringAnnotation("app-root", ing)
|
||||
config.UseRegex, _ = parser.GetBoolAnnotation("use-regex", ing)
|
||||
|
||||
config.AppRoot, err = parser.GetStringAnnotation("app-root", ing)
|
||||
if err != nil {
|
||||
if !errors.IsMissingAnnotations(err) && !errors.IsInvalidContent(err) {
|
||||
klog.Warningf("Annotation app-root contains an invalid value: %v", err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
u, err := url.ParseRequestURI(config.AppRoot)
|
||||
if err != nil {
|
||||
klog.Warningf("Annotation app-root contains an invalid value: %v", err)
|
||||
config.AppRoot = ""
|
||||
return config, nil
|
||||
}
|
||||
|
||||
if u.IsAbs() {
|
||||
klog.Warningf("Annotation app-root only allows absolute paths (%v)", config.AppRoot)
|
||||
config.AppRoot = ""
|
||||
return config, nil
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue