From 932780c2bbae09f052e2fcd1a0701966483496e8 Mon Sep 17 00:00:00 2001 From: Kane <61651662+yarg-kane@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:48:26 +0200 Subject: [PATCH] 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 --- .../doc/usage/reverse-proxies.en-us.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/content/doc/usage/reverse-proxies.en-us.md b/docs/content/doc/usage/reverse-proxies.en-us.md index 9a2552b711..72998609d9 100644 --- a/docs/content/doc/usage/reverse-proxies.en-us.md +++ b/docs/content/doc/usage/reverse-proxies.en-us.md @@ -292,3 +292,50 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a ``` + +## HAProxy + +If you want HAProxy to serve your Gitea instance, you can add the following to your HAProxy configuration + +add an acl in the frontend section to redirect calls to gitea.example.com to the correct backend +``` +frontend http-in + ... + acl acl_gitea hdr(host) -i gitea.example.com + use_backend gitea if acl_gitea + ... +``` + +add the previously defined backend section +``` +backend gitea + server localhost:3000 check +``` + +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. + +## HAProxy with a sub-path + +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: + +``` +frontend http-in + ... + acl acl_gitea path_beg /gitea + use_backend gitea if acl_gitea + ... +``` + +With that configuration http://example.com/gitea/ will redirect to your Gitea instance. + +then for the backend section +``` +backend gitea + http-request replace-path /gitea\/?(.*) \/\1 + server localhost:3000 check +``` + +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. + +Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration. +