aboutsummaryrefslogtreecommitdiff
path: root/modules/setting/setting.go
diff options
context:
space:
mode:
author无闻 <joe2010xtmf@163.com>2014-09-19 19:02:40 -0400
committer无闻 <joe2010xtmf@163.com>2014-09-19 19:02:40 -0400
commit6a7bd097fe2b3e894830fc3fdb60dde5594b61d6 (patch)
tree64a9ea617ba1f704139881c3960fa2425dad9018 /modules/setting/setting.go
parent4f74b4e6578be4251af65cd08daa37c884e431a0 (diff)
parent0055cbd3651ebde0f8b6cc70c9c44de56dc38830 (diff)
Merge pull request #463 from chadoe/urlroot
Allow Gogs to run from a suburl behind a reverse proxy.
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r--modules/setting/setting.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 5fb1d52d..74427744 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -6,6 +6,7 @@ package setting
import (
"fmt"
+ "net/url"
"os"
"os/exec"
"path"
@@ -31,9 +32,10 @@ const (
var (
// App settings.
- AppVer string
- AppName string
- AppUrl string
+ AppVer string
+ AppName string
+ AppUrl string
+ AppRootSubUrl string
// Server settings.
Protocol Scheme
@@ -165,6 +167,12 @@ func NewConfigContext() {
AppUrl += "/"
}
+ url, err := url.Parse(AppUrl)
+ if err != nil {
+ log.Fatal(4, "Invalid ROOT_URL %s: %s", AppUrl, err)
+ }
+ AppRootSubUrl = strings.TrimSuffix(url.Path, "/")
+
Protocol = HTTP
if Cfg.MustValue("server", "PROTOCOL") == "https" {
Protocol = HTTPS