{"WARNING": "This file is automatically generated by act-runner. Do not edit it manually unless you know what you are doing. Removing this file will cause act runner to re-register as a new runner.","id": 1,"uuid": "9915f68d-7d47-4731-b329-aa53ff8ba01f","name": "runner1","token": "276147af85ea87c3fce5caeef0c93012e6486e89","address": "http://192.168.50.117:3000","labels": ["runner1:host" ]}
func GuessCurrentHostURL(ctx context.Context) string { req, ok := ctx.Value(RequestContextKey).(*http.Request)if!ok {return strings.TrimSuffix(setting.AppURL, setting.AppSubURL+"/") }// If no scheme provided by reverse proxy, then do not guess the AppURL, use the configured one.// At the moment, if site admin doesn't configure the proxy headers correctly, then Gitea would guess wrong.// There are some cases:// 1. The reverse proxy is configured correctly, it passes "X-Forwarded-Proto/Host" headers. Perfect, Gitea can handle it correctly.// 2. The reverse proxy is not configured correctly, doesn't pass "X-Forwarded-Proto/Host" headers, eg: only one "proxy_pass http://gitea:3000" in Nginx.// 3. There is no reverse proxy.// Without an extra config option, Gitea is impossible to distinguish between case 2 and case 3,// then case 2 would result in wrong guess like guessed AppURL becomes "http://gitea:3000/", which is not accessible by end users.// So in the future maybe it should introduce a new config option, to let site admin decide how to guess the AppURL.reqScheme :=getRequestScheme(req)if reqScheme =="" {return strings.TrimSuffix(setting.AppURL, setting.AppSubURL+"/") }// X-Forwarded-Host has many problems: non-standard, not well-defined (X-Forwarded-Port or not), conflicts with Host header.// So do not use X-Forwarded-Host, just use Host header directly.return reqScheme +"://"+ req.Host # 就是这里}