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: docs/content/administration/reverse-proxies.en-us.md
+35-35
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,35 @@ menu:
17
17
18
18
# Reverse Proxies
19
19
20
+
## General configuration
21
+
22
+
1. Set `[server] ROOT_URL = https://git.example.com/` in your `app.ini` file.
23
+
2. Make the reverse-proxy pass `https://git.example.com/foo` to `http://gitea:3000/foo`.
24
+
3. Make sure the reverse-proxy not decode the URI, the request `https://git.example.com/a%2Fb` should be passed as `http://gitea:3000/a%2Fb`.
25
+
4. Make sure `Host` and `X-Fowarded-Proto` headers are correctly passed to Gitea to make sure Gitea sees the real URL being visited.
26
+
27
+
### Use a sub-path
28
+
29
+
Usually it's **not recommended** to put Gitea in a sub-path, it's not widely used and may have some issues in rare cases.
30
+
31
+
If you really need to do so, to make Gitea work with sub-path (eg: `https://common.example.com/gitea/`),
32
+
here are the extra requirements besides the general configuration above:
33
+
34
+
1. Use `[server] ROOT_URL = https://common.example.com/gitea/` in your `app.ini` file.
35
+
2. Make the reverse-proxy pass `https://common.example.com/gitea/foo` to `http://gitea:3000/foo`.
36
+
3. If you'd like to use container registry, the container registry uses a fixed sub-path `/v2` in the root, which is unchangeable and required by container registry standard.
37
+
- Make reverse-proxy pass `https://common.example.com/v2` to `http://gitea:3000/v2`.
38
+
- Make sure the URI and headers are also correctly passed (see the general configuration above).
39
+
20
40
## Nginx
21
41
22
-
If you want Nginx to serve your Gitea instance, add the following `server` section to the `http` section of `nginx.conf`:
42
+
If you want Nginx to serve your Gitea instance, add the following `server` section to the `http` section of `nginx.conf`.
43
+
44
+
And make sure `client_max_body_size` is large enough, otherwise there would be "413 Request Entity Too Large" error when uploading large files.
23
45
24
46
```
25
47
server {
26
-
listen 80;
27
-
server_name git.example.com;
28
-
48
+
...
29
49
location / {
30
50
client_max_body_size 512M;
31
51
proxy_pass http://localhost:3000;
@@ -39,21 +59,13 @@ server {
39
59
}
40
60
```
41
61
42
-
### Resolving Error: 413 Request Entity Too Large
43
-
44
-
This error indicates nginx is configured to restrict the file upload size,
45
-
it affects attachment uploading, form posting, package uploading and LFS pushing, etc.
46
-
You can fine tune the `client_max_body_size` option according to [nginx document](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size).
47
-
48
62
## Nginx with a sub-path
49
63
50
64
In case you already have a site, and you want Gitea to share the domain name, you can setup Nginx to serve Gitea under a sub-path by adding the following `server` section inside the `http` section of `nginx.conf`:
51
65
52
66
```
53
67
server {
54
-
listen 80;
55
-
server_name git.example.com;
56
-
68
+
...
57
69
# Note: Trailing slash
58
70
location /gitea/ {
59
71
client_max_body_size 512M;
@@ -69,7 +81,7 @@ server {
69
81
}
70
82
```
71
83
72
-
Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/git/` correctly in your configuration.
84
+
Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/gitea/` correctly in your configuration.
73
85
74
86
## Nginx and serve static resources directly
75
87
@@ -93,7 +105,7 @@ or use a cdn for the static files.
93
105
94
106
Set `[server] STATIC_URL_PREFIX = /_/static` in your configuration.
95
107
96
-
```apacheconf
108
+
```
97
109
server {
98
110
listen 80;
99
111
server_name git.example.com;
@@ -112,7 +124,7 @@ server {
112
124
113
125
Set `[server] STATIC_URL_PREFIX = http://cdn.example.com/gitea` in your configuration.
114
126
115
-
```apacheconf
127
+
```
116
128
# application server running Gitea
117
129
server {
118
130
listen 80;
@@ -124,7 +136,7 @@ server {
124
136
}
125
137
```
126
138
127
-
```apacheconf
139
+
```
128
140
# static content delivery server
129
141
server {
130
142
listen 80;
@@ -151,6 +163,8 @@ If you want Apache HTTPD to serve your Gitea instance, you can add the following
151
163
ProxyRequests off
152
164
AllowEncodedSlashes NoDecode
153
165
ProxyPass / http://localhost:3000/ nocanon
166
+
ProxyPreserveHost On
167
+
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
154
168
</VirtualHost>
155
169
```
156
170
@@ -172,6 +186,8 @@ In case you already have a site, and you want Gitea to share the domain name, yo
172
186
AllowEncodedSlashes NoDecode
173
187
# Note: no trailing slash after either /git or port
174
188
ProxyPass /git http://localhost:3000 nocanon
189
+
ProxyPreserveHost On
190
+
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
175
191
</VirtualHost>
176
192
```
177
193
@@ -183,7 +199,7 @@ Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`.
183
199
184
200
If you want Caddy to serve your Gitea instance, you can add the following server block to your Caddyfile:
185
201
186
-
```apacheconf
202
+
```
187
203
git.example.com {
188
204
reverse_proxy localhost:3000
189
205
}
@@ -193,7 +209,7 @@ git.example.com {
193
209
194
210
In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile:
195
211
196
-
```apacheconf
212
+
```
197
213
git.example.com {
198
214
route /git/* {
199
215
uri strip_prefix /git
@@ -371,19 +387,3 @@ gitea:
371
387
This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik.
372
388
373
389
Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration.
374
-
375
-
## General sub-path configuration
376
-
377
-
Usually it's not recommended to put Gitea in a sub-path, it's not widely used and may have some issues in rare cases.
378
-
379
-
If you really need to do so, to make Gitea works with sub-path (eg: `http://example.com/gitea/`), here are the requirements:
380
-
381
-
1. Set `[server] ROOT_URL = http://example.com/gitea/` in your `app.ini` file.
382
-
2. Make the reverse-proxy pass `http://example.com/gitea/foo` to `http://gitea-server:3000/foo`.
383
-
3. Make sure the reverse-proxy not decode the URI, the request `http://example.com/gitea/a%2Fb` should be passed as `http://gitea-server:3000/a%2Fb`.
384
-
385
-
## Docker / Container Registry
386
-
387
-
The container registry uses a fixed sub-path `/v2` which can't be changed.
388
-
Even if you deploy Gitea with a different sub-path, `/v2` will be used by the `docker` client.
389
-
Therefore you may need to add an additional route to your reverse proxy configuration.
0 commit comments