http: add "Use reverse proxy host" option

added "Use reverse-proxy reported "Host" when possible" option, which
will prefer using the "Host" or "X-Forwarded-Host" values instead of
"External jfa-go URL" in the web app. To do so, app.ExternalDomain/URI
are now functions which take *gin.Context (the latter optionally). The
protocol for the request is determined from X-Forwarded-Proto(col), so
make sure your proxy includes it.

The wiki will have been updated to mention the new option.
This commit is contained in:
Harvey Tindall
2025-07-16 15:00:46 +01:00
parent 41ddf73e4f
commit 7cb66e26e5
9 changed files with 69 additions and 29 deletions
+2 -3
View File
@@ -266,8 +266,7 @@ func (app *appContext) getTokenLogin(gc *gin.Context) {
respond(500, "Couldn't generate token", gc)
return
}
// host := gc.Request.URL.Hostname()
host := app.ExternalDomain
host := app.ExternalDomain(gc)
// Before you think this is broken: the first "true" arg is for "secure", i.e. only HTTPS!
gc.SetCookie("refresh", refresh, REFRESH_TOKEN_VALIDITY_SEC, "/", host, true, true)
@@ -329,7 +328,7 @@ func (app *appContext) getTokenRefresh(gc *gin.Context) {
return
}
// host := gc.Request.URL.Hostname()
host := app.ExternalDomain
host := app.ExternalDomain(gc)
gc.SetCookie("refresh", refresh, REFRESH_TOKEN_VALIDITY_SEC, "/", host, true, true)
gc.JSON(200, getTokenDTO{jwt})
}