diff --git a/config.go b/config.go index c2c50ab..075294a 100644 --- a/config.go +++ b/config.go @@ -13,6 +13,7 @@ import ( type Configuration struct { Listen string `config:"tcp://:8080"` Host string `config:"localhost:8080"` + ExtOrigin string `config:""` // consider lfs-test-server may behind a reverse proxy MetaDB string `config:"lfs.db"` ContentPath string `config:"lfs-content"` AdminUser string `config:""` @@ -74,4 +75,8 @@ func init() { // If $PORT is set, override LFS_LISTEN. This is useful for deploying to Heroku. Config.Listen = "tcp://:" + port } + + if Config.ExtOrigin == "" { + Config.ExtOrigin = fmt.Sprintf("%s://%s", Config.Scheme, Config.Host) + } } diff --git a/mgmt/templates/config.tmpl b/mgmt/templates/config.tmpl index 3c83082..da50a75 100644 --- a/mgmt/templates/config.tmpl +++ b/mgmt/templates/config.tmpl @@ -1,14 +1,14 @@
URL: {{.Config.Scheme}}://{{.Config.Host}}
+URL: {{.Config.ExtOrigin}}
Listen Address: {{.Config.Listen}}
Database: {{.Config.MetaDB}}
Content: {{.Config.ContentPath}}
To configure a repository to use this LFS server, add the following to the repository's .gitconfig
file:
To configure a repository to use this LFS server, add the following to the repository's Git config or .lfsconfig
file:
[lfs]
- url = "{{.Config.Scheme}}://{{.Config.Host}}/"
+ url = "{{.Config.ExtOrigin}}"
diff --git a/server.go b/server.go
index 0da201b..d9255bf 100644
--- a/server.go
+++ b/server.go
@@ -131,11 +131,7 @@ func (v *RequestVars) internalLink(subpath string) string {
path += fmt.Sprintf("/%s/%s", subpath, v.Oid)
- if Config.IsHTTPS() {
- return fmt.Sprintf("%s://%s%s", Config.Scheme, Config.Host, path)
- }
-
- return fmt.Sprintf("http://%s%s", Config.Host, path)
+ return fmt.Sprintf("%s%s", Config.ExtOrigin, path)
}
func (v *RequestVars) tusLink() string {
@@ -149,11 +145,7 @@ func (v *RequestVars) tusLink() string {
func (v *RequestVars) VerifyLink() string {
path := fmt.Sprintf("/verify/%s", v.Oid)
- if Config.IsHTTPS() {
- return fmt.Sprintf("%s://%s%s", Config.Scheme, Config.Host, path)
- }
-
- return fmt.Sprintf("http://%s%s", Config.Host, path)
+ return fmt.Sprintf("%s%s", Config.ExtOrigin, path)
}
// link provides a structure used to build a hypermedia representation of an HTTP link.