#2229 adjust URL verbose depth for reverse proxy sub-path
This commit is contained in:
parent
57c10aae33
commit
4848620594
5 changed files with 15 additions and 10 deletions
|
@ -21,6 +21,8 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
// TODO: put this into 'markdown' module.
|
||||
|
||||
func isletter(c byte) bool {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||
}
|
||||
|
@ -187,7 +189,7 @@ func cutoutVerbosePrefix(prefix string) string {
|
|||
if prefix[i] == '/' {
|
||||
count++
|
||||
}
|
||||
if count >= 3 {
|
||||
if count >= 3+setting.AppSubUrlDepth {
|
||||
return prefix[:i]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,13 @@ var (
|
|||
BuildGitHash string
|
||||
|
||||
// App settings
|
||||
AppVer string
|
||||
AppName string
|
||||
AppUrl string
|
||||
AppSubUrl string
|
||||
AppPath string
|
||||
AppDataPath = "data"
|
||||
AppVer string
|
||||
AppName string
|
||||
AppUrl string
|
||||
AppSubUrl string
|
||||
AppSubUrlDepth int // Number of slashes
|
||||
AppPath string
|
||||
AppDataPath = "data"
|
||||
|
||||
// Server settings
|
||||
Protocol Scheme
|
||||
|
@ -299,7 +300,9 @@ func NewContext() {
|
|||
if err != nil {
|
||||
log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppUrl, err)
|
||||
}
|
||||
// Suburl should start with '/' and end without '/', such as '/{subpath}'.
|
||||
AppSubUrl = strings.TrimSuffix(url.Path, "/")
|
||||
AppSubUrlDepth = strings.Count(AppSubUrl, "/")
|
||||
|
||||
Protocol = HTTP
|
||||
if sec.Key("PROTOCOL").String() == "https" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue