Setting custom environment variables
- Tier: Free, Premium, Ultimate
- Offering: Self-managed
If necessary you can set custom environment variables to be used by Puma,
Sidekiq, Rails and Rake via /etc/gitlab/gitlab.rb
. This can be useful in
situations where you need to use a proxy to access the internet and need to
clone externally hosted repositories directly into GitLab. In
/etc/gitlab/gitlab.rb
supply a gitlab_rails['env']
with a hash value. For
example:
gitlab_rails['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
# "no_proxy" => ".yourdomain.com" # Wildcard syntax if you need your internal domain to bypass proxy
}
You can also override environment variables from other GitLab components which might be required if you are behind a proxy:
# Needed for proxying Git clones
gitaly['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
}
gitlab_workhorse['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
}
gitlab_pages['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
}
# If you use the docker registry
registry['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
}
GitLab will attempt to use HTTP Basic Authentication when a username and password is included in the proxy URL.
Proxy settings use the .
syntax for globing.
Proxy URL values should generally be http://
only, unless
your proxy has its own SSL certificate and SSL enabled. This means, even for
the https_proxy
value, you should usually specify a value as
http://<USERNAME>:<PASSWORD>@example.com:8080
.
DNS rebind protection is disabled when either the HTTP_PROXY or the HTTPS_PROXY environment variable is set, and the domain DNS can’t be resolved.
Applying the changes
Any change made to the environment variables requires a reconfigure for it to take effect.
Perform a reconfigure:
sudo gitlab-ctl reconfigure
Troubleshooting
An environment variable is not being set
Check that you don’t have multiple entries for the same ['env']
. The last one will override
previous entries. In this example, NTP_HOST
will not be set:
gitlab_rails['env'] = { 'NTP_HOST' => "<DOMAIN_OF_NTP_SERVICE>" }
gitlab_rails['env'] = {
"http_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080",
"https_proxy" => "http://<USERNAME>:<PASSWORD>@example.com:8080"
}
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support