doc/development/workhorse/_index.md
GitLab Workhorse is a smart reverse proxy for GitLab intended to handle resource-intensive and long-running requests.
It sits in front of Puma and intercepts every HTTP request destined for and emitted from GitLab Rails.
Rails delegates requests to Workhorse and it takes responsibility for resource intensive HTTP requests
such as file downloads and uploads, git over HTTP push/pull and git over HTTP archive downloads,
which optimizes resource utilization and improves request handling efficiency.
Workhorse can have other reverse proxy servers in front of it but only NGINX is supported.
It is also possible (although unsupported) to use other reverse proxies such as Apache when installing
GitLab from source.
On many instances of GitLab, such as gitlab.com, a CDN like CloudFlare sits in front of NGINX.
Every Rails controller and other code that handles HTTP requests and returning HTTP responses is proxied through GitLab Workhorse. Workhorse is unlike other reverse proxies as it is tightly coupled to GitLab Rails, whereas most reverse proxies are more generic. When required, Workhorse makes modifications to HTTP headers which GitLab Rails depends on to offload work efficiently.
[!warning] When developing new features in Workhorse that involves Gitaly, you must follow the guidelines regarding Gitaly version compatibility requirement.
Workhorse serves as a proxy to the Rails API, especially in contexts requiring interaction with container registry services. This setup exemplifies Workhorse's handling of high-load services by acting as a reverse proxy, thereby minimizing the direct load on Rails.
Workhorse is contained in a subfolder of the Rails monorepo at
gitlab-org/gitlab/workhorse.
To install GitLab Workhorse you need Go 1.18 or newer and GNU Make.
To install into /usr/local/bin run make install.
make install
To install into /foo/bin set the PREFIX variable.
make install PREFIX=/foo
On some operating systems, such as FreeBSD, you may have to use
gmake instead of make.
[!note] Some features depend on build tags, make sure to check Workhorse configuration to enable them.
Workhorse uses ExifTool for removing EXIF data (which may contain sensitive information) from uploaded images. If you installed GitLab:
Using the Linux package, you're all set.
If you are using CentOS Minimal, you may need to install perl package: yum install perl.
From source, make sure exiftool is installed:
# Debian/Ubuntu
sudo apt-get install libimage-exiftool-perl
# RHEL/CentOS
sudo yum install perl-Image-ExifTool
Run the tests with:
make clean test
Each feature in GitLab Workhorse should have an integration test that verifies that the feature 'kicks in' on the right requests and leaves other requests unaffected. It is better to also have package-level tests for specific behavior but the high-level integration tests should have the first priority during development.
It is OK if a feature is only covered by integration tests.