From fa8d40facab6d3cba0bd95a3c882edfc28d478fd Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Thu, 3 Aug 2017 18:32:13 +0300 Subject: 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 --- modules/setting/setting.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'modules/setting') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5bd2495287..8cd9fa6086 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -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) -- cgit v1.2.3