From 0055cbd3651ebde0f8b6cc70c9c44de56dc38830 Mon Sep 17 00:00:00 2001 From: Martin van Beurden Date: Sun, 14 Sep 2014 19:35:22 +0200 Subject: Allow Gogs to run from a suburl behind a reverse proxy. e.g. http://mydomain.com/gogs/ Conflicts: modules/setting/setting.go Conflicts: templates/repo/release/list.tmpl templates/user/dashboard/dashboard.tmpl Conflicts: routers/repo/setting.go --- modules/setting/setting.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'modules/setting') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5fb1d52d0b..7442774488 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 -- cgit v1.2.3