1
0
Fork 0
forked from forgejo/forgejo

Fix internal requests when gitea listens to unix socket or only external IP (#2234)

* Fix internal requests when gitea listens to unix socket or only external IP

* When Gitea is set to listen using FastCGI use AppURL for LocalURL
This commit is contained in:
Lauris BH 2017-08-03 18:32:13 +03:00 committed by Lunny Xiao
parent a4ca54425f
commit fa8d40faca
4 changed files with 34 additions and 12 deletions

View file

@ -658,7 +658,22 @@ func NewContext() {
AppSubURL = strings.TrimSuffix(url.Path, "/")
AppSubURLDepth = strings.Count(AppSubURL, "/")
LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
var defaultLocalURL string
switch Protocol {
case UnixSocket:
defaultLocalURL = "http://unix/"
case FCGI:
defaultLocalURL = AppURL
default:
defaultLocalURL = string(Protocol) + "://"
if HTTPAddr == "0.0.0.0" {
defaultLocalURL += "localhost"
} else {
defaultLocalURL += HTTPAddr
}
defaultLocalURL += ":" + HTTPPort + "/"
}
LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)