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
Copy file name to clipboardExpand all lines: custom/conf/app.example.ini
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -63,14 +63,18 @@ RUN_USER = ; git
63
63
;PROTOCOL = http
64
64
;;
65
65
;; Set the domain for the server.
66
-
;; Most users should set it to the real website domain of their Gitea instance.
67
66
;DOMAIN = localhost
68
67
;;
69
-
;; The AppURL used by Gitea to generate absolute links, defaults to "{PROTOCOL}://{DOMAIN}:{HTTP_PORT}/".
68
+
;; The AppURL is used to generate public URL links, defaults to "{PROTOCOL}://{DOMAIN}:{HTTP_PORT}/".
70
69
;; Most users should set it to the real website URL of their Gitea instance when there is a reverse proxy.
71
-
;; When it is empty, Gitea will use HTTP "Host" header to generate ROOT_URL, and fall back to the default one if no "Host" header.
72
70
;ROOT_URL =
73
71
;;
72
+
;; Controls how to generate the public URL. Most users should leave it empty to use the "auto" behavior.
73
+
;; * auto: generate the public URL automatically by X-Forwarded-Proto and Host headers in the request
74
+
;; * use-host: if "auto" fails (no X-Forwarded-Proto header), still use the value of Host header in the request, scheme will be "https" if PROTOCOL=https
75
+
;; * fixed: ignore the HTTP headers in the request, only use the configured ROOT_URL value for public URL
76
+
;PUBLIC_URL_GENERATION = auto
77
+
;;
74
78
;; For development purpose only. It makes Gitea handle sub-path ("/sub-path/owner/repo/...") directly when debugging without a reverse proxy.
// GuessCurrentAppURL tries to guess the current full app URL (with sub-path) by http headers. It always has a '/' suffix, exactly the same as setting.AppURL
56
+
// GuessCurrentAppURL tries to guess the current full public URL (with sub-path) by http headers. It always has a '/' suffix, exactly the same as setting.AppURL
57
+
// TODO: should rename it to GuessCurrentPublicURL in the future
// If no scheme provided by reverse proxy, then do not guess the AppURL, use the configured one.
67
+
// Try the best guess to get the current host URL (will be used for public URL) by http headers.
68
68
// At the moment, if site admin doesn't configure the proxy headers correctly, then Gitea would guess wrong.
69
69
// There are some cases:
70
70
// 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
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
74
+
// wrong guess like guessed public URL becomes "http://gitea:3000/" behind a "https" reverse proxy, which is not accessible by end users.
75
+
// So we introduced "PUBLIC_URL_GENERATION" option, to control the guessing behavior to satisfy different use cases.
0 commit comments