2020-06-03 16:04:07 +00:00
---
2022-09-21 18:19:11 +00:00
stage: Systems
2020-06-03 16:04:07 +00:00
group: Distribution
2023-12-05 03:40:46 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-06-03 16:04:07 +00:00
---
2024-01-24 07:29:14 +00:00
# Setting custom environment variables
DETAILS:
**Tier:** Free, Premium, Ultimate
**Offering:** Self-managed
2014-11-03 15:16:30 +00:00
2020-05-07 19:14:45 +00:00
If necessary you can set custom environment variables to be used by Puma,
2020-03-18 06:38:21 +00:00
Sidekiq, Rails and Rake via `/etc/gitlab/gitlab.rb` . This can be useful in
2019-08-14 06:16:26 +00:00
situations where you need to use a proxy to access the internet and need to
2020-03-18 06:38:21 +00:00
clone externally hosted repositories directly into GitLab. In
2014-11-03 15:16:30 +00:00
`/etc/gitlab/gitlab.rb` supply a `gitlab_rails['env']` with a hash value. For
example:
```ruby
2018-05-31 16:37:55 +00:00
gitlab_rails['env'] = {
2019-08-14 06:16:26 +00:00
"http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
"https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
2019-08-22 08:30:57 +00:00
# "no_proxy" => ".yourdomain.com" # Wildcard syntax if you need your internal domain to bypass proxy
2018-05-31 16:37:55 +00:00
}
```
You can also override environment variables from other GitLab components which
might be required if you are behind a proxy:
```ruby
2018-11-13 05:09:57 +00:00
# Needed for proxying Git clones
gitaly['env'] = {
2019-08-14 06:16:26 +00:00
"http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
2020-10-22 23:11:22 +00:00
"https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
2018-11-13 05:09:57 +00:00
}
2018-05-31 16:37:55 +00:00
gitlab_workhorse['env'] = {
2019-08-14 06:16:26 +00:00
"http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
"https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
2018-05-31 16:37:55 +00:00
}
2020-06-08 02:39:44 +00:00
gitlab_pages['env'] = {
"http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
"https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
}
2018-05-31 16:37:55 +00:00
# If you use the docker registry
registry['env'] = {
2019-08-14 06:16:26 +00:00
"http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
"https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
2018-05-31 16:37:55 +00:00
}
2014-11-03 15:16:30 +00:00
```
2024-04-23 20:34:58 +00:00
GitLab will attempt to use HTTP Basic Authentication when a username and password is included in the proxy URL.
2018-12-17 10:49:58 +00:00
2020-08-10 02:37:54 +00:00
Proxy settings use the `.` syntax for globing.
2019-08-14 06:16:26 +00:00
2020-08-10 02:37:54 +00:00
Proxy URL values should generally be `http://` only, unless
2019-08-14 06:16:26 +00:00
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` .
2018-11-20 00:04:37 +00:00
2023-02-08 00:23:35 +00:00
NOTE:
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.
2017-05-30 11:40:18 +00:00
## Applying the changes
2022-06-20 13:18:28 +00:00
Any change made to the environment variables requires a reconfigure for it
to take effect.
2017-05-30 11:40:18 +00:00
2021-06-14 13:14:03 +00:00
Perform a reconfigure:
2017-05-30 11:40:18 +00:00
```shell
sudo gitlab-ctl reconfigure
```