aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorMartin van Beurden <chadoe@gmail.com>2014-09-14 19:35:22 +0200
committerMartin van Beurden <chadoe@gmail.com>2014-09-18 20:50:48 +0200
commit0055cbd3651ebde0f8b6cc70c9c44de56dc38830 (patch)
tree64a9ea617ba1f704139881c3960fa2425dad9018 /modules/setting
parent4f74b4e6578be4251af65cd08daa37c884e431a0 (diff)
downloadgitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.tar.gz
gitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.zip
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
Diffstat (limited to 'modules/setting')
-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 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