You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 1. The reverse proxy is configured correctly, it passes "X-Forwarded-Proto/Host" headers. Perfect, Gitea can handle it correctly.
71
71
// 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.
72
72
// 3. There is no reverse proxy.
73
-
// With the "USE_HOST_HEADER" config option disabled (default), Gitea is impossible to distinguish between case 2 and case 3,
74
-
// When enabling "USE_HOST_HEADER", any reverse proxies must be configured to properly pass "X-Forwarded-Proto/Host" headers,
75
-
// otherwise this would result in wrong guess like guessed AppURL becomes "http://gitea:3000/", which is not accessible by end users.
73
+
// Without more information, Gitea is impossible to distinguish between case 2 and case 3, then case 2 would result in
74
+
// wrong guess like guessed AppURL becomes "http://gitea:3000/" behind a "https" reverse proxy, which is not accessible by end users.
75
+
// So we introduced "UseHostHeader" option, it could be enabled by setting "ROOT_URL" to empty
76
76
reqScheme:=getRequestScheme(req)
77
77
ifreqScheme=="" {
78
+
// if no reverse proxy header, try to use "Host" header for absolute URL
Copy file name to clipboardExpand all lines: modules/setting/server.go
+31-15Lines changed: 31 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -46,29 +46,37 @@ var (
46
46
// AppURL is the Application ROOT_URL. It always has a '/' suffix
47
47
// It maps to ini:"ROOT_URL"
48
48
AppURLstring
49
-
// AppSubURL represents the sub-url mounting point for gitea. It is either "" or starts with '/' and ends without '/', such as '/{subpath}'.
49
+
50
+
// AppSubURL represents the sub-url mounting point for gitea, parsed from "ROOT_URL"
51
+
// It is either "" or starts with '/' and ends without '/', such as '/{sub-path}'.
50
52
// This value is empty if site does not have sub-url.
51
53
AppSubURLstring
52
-
// UseSubURLPath makes Gitea handle requests with sub-path like "/sub-path/owner/repo/...", to make it easier to debug sub-path related problems without a reverse proxy.
54
+
55
+
// UseSubURLPath makes Gitea handle requests with sub-path like "/sub-path/owner/repo/...",
56
+
// to make it easier to debug sub-path related problems without a reverse proxy.
53
57
UseSubURLPathbool
54
-
// UseHostHeader makes Gitea always use the "Host" request header for construction of absolute URLs.
55
-
// This requires any reverse proxy to properly pass headers like "X-Forwarded-Proto" and "Host".
56
-
// It maps to ini:"USE_HOST_HEADER" in [server] and defaults to false
58
+
59
+
// UseHostHeader makes Gitea prefer to use the "Host" request header for construction of absolute URLs.
57
60
UseHostHeaderbool
61
+
58
62
// AppDataPath is the default path for storing data.
59
63
// It maps to ini:"APP_DATA_PATH" in [server] and defaults to AppWorkPath + "/data"
60
64
AppDataPathstring
65
+
61
66
// LocalURL is the url for locally running applications to contact Gitea. It always has a '/' suffix
62
67
// It maps to ini:"LOCAL_ROOT_URL" in [server]
63
68
LocalURLstring
64
-
// AssetVersion holds a opaque value that is used for cache-busting assets
69
+
70
+
// AssetVersion holds an opaque value that is used for cache-busting assets
65
71
AssetVersionstring
66
72
67
-
appTempPathInternalstring// the temporary path for the app, it is only an internal variable, do not use it, always use AppDataTempDir
73
+
// appTempPathInternal is the temporary path for the app, it is only an internal variable
74
+
// DO NOT use it directly, always use AppDataTempDir
0 commit comments