Skip to content

Commit 932780c

Browse files
author
Kane
authored
Add HAProxy Config to reverse-proxies.en-us.md (#17407)
* Update reverse-proxies.en-us.md Addition of HAProxy * Update reverse-proxies.en-us.md
1 parent 07c7100 commit 932780c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,50 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
292292
</system.webServer>
293293
</configuration>
294294
```
295+
296+
## HAProxy
297+
298+
If you want HAProxy to serve your Gitea instance, you can add the following to your HAProxy configuration
299+
300+
add an acl in the frontend section to redirect calls to gitea.example.com to the correct backend
301+
```
302+
frontend http-in
303+
...
304+
acl acl_gitea hdr(host) -i gitea.example.com
305+
use_backend gitea if acl_gitea
306+
...
307+
```
308+
309+
add the previously defined backend section
310+
```
311+
backend gitea
312+
server localhost:3000 check
313+
```
314+
315+
If you redirect the http content to https, the configuration work the same way, just remember that the connexion between HAProxy and Gitea will be done via http so you do not have to enable https in Gitea's configuration.
316+
317+
## HAProxy with a sub-path
318+
319+
In case you already have a site, and you want Gitea to share the domain name, you can setup HAProxy to serve Gitea under a sub-path by adding the following to you HAProxy configuration:
320+
321+
```
322+
frontend http-in
323+
...
324+
acl acl_gitea path_beg /gitea
325+
use_backend gitea if acl_gitea
326+
...
327+
```
328+
329+
With that configuration http://example.com/gitea/ will redirect to your Gitea instance.
330+
331+
then for the backend section
332+
```
333+
backend gitea
334+
http-request replace-path /gitea\/?(.*) \/\1
335+
server localhost:3000 check
336+
```
337+
338+
The added http-request will automatically add a trailing slash if needed and internally remove /gitea from the path to allow it to work correctly with Gitea by setting properly http://example.com/gitea as the root.
339+
340+
Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration.
341+

0 commit comments

Comments
 (0)