for the web interfaces, ensure the effective configured http paths end in a slash to prevent 404's and/or errors accessing the web interfaces

The default paths for the web interfaces, such as /admin/, /account/, /webmail/
and /webapi/ end with a slash. They should end with a slash because we use the
path when restricting cookies to just that web interface. You could configure
paths not ending with a slash, but due to using http.StripPrefix, and our
handler, some of those requests may not work properly.

We now warn if configured paths don't end with a trailing slash when parsing
the config file. We normally error out when such things happen, but users
probably have paths without trailing slashes configured, and we don't want to
break them on a future upgrade. We now use an effective path that includes the
trailing slash.

We would always redirect requests to the configured paths but without trailing
slash to the path with trailing slash, and that stays.

For issue #325 by odama626.
This commit is contained in:
Mechiel Lukkien
2025-03-29 21:48:56 +01:00
parent 3a3a11560e
commit 3e128d744e
4 changed files with 44 additions and 25 deletions

View File

@ -222,7 +222,7 @@ type Listener struct {
type WebService struct {
Enabled bool
Port int `sconf:"optional" sconf-doc:"Default 80 for HTTP and 443 for HTTPS. See Hostname at Listener for hostname matching behaviour."`
Path string `sconf:"optional" sconf-doc:"Path to serve requests on."`
Path string `sconf:"optional" sconf-doc:"Path to serve requests on. Should end with a slash, related to cookie paths."`
Forwarded bool `sconf:"optional" sconf-doc:"If set, X-Forwarded-* headers are used for the remote IP address for rate limiting and for the \"secure\" status of cookies."`
}

View File

@ -333,7 +333,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -349,7 +350,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -368,7 +370,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -384,7 +387,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -399,7 +403,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -415,7 +420,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -430,7 +436,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate
@ -446,7 +453,8 @@ See https://pkg.go.dev/github.com/mjl-/sconf for details.
# matching behaviour. (optional)
Port: 0
# Path to serve requests on. (optional)
# Path to serve requests on. Should end with a slash, related to cookie paths.
# (optional)
Path:
# If set, X-Forwarded-* headers are used for the remote IP address for rate