environment-variables.md 2.5 KB
Newer Older
1
2
3
4
5
6
---
stage: Enablement
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---

Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
7
# Setting custom environment variables **(FREE SELF)**
8

9
If necessary you can set custom environment variables to be used by Puma,
Evan Read's avatar
Evan Read committed
10
Sidekiq, Rails and Rake via `/etc/gitlab/gitlab.rb`. This can be useful in
11
situations where you need to use a proxy to access the internet and need to
Evan Read's avatar
Evan Read committed
12
clone externally hosted repositories directly into GitLab. In
13
14
15
16
`/etc/gitlab/gitlab.rb` supply a `gitlab_rails['env']` with a hash value. For
example:

```ruby
17
gitlab_rails['env'] = {
18
19
    "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
    "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
20
#    "no_proxy" => ".yourdomain.com"  # Wildcard syntax if you need your internal domain to bypass proxy
21
22
23
24
25
26
27
}
```

You can also override environment variables from other GitLab components which
might be required if you are behind a proxy:

```ruby
28
29
# Needed for proxying Git clones
gitaly['env'] = {
30
    "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
31
    "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
32
33
}

34
gitlab_workhorse['env'] = {
35
36
    "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
    "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
37
38
}

39
40
41
42
43
gitlab_pages['env'] = {
    "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
    "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
}

44
45
# If you use the docker registry
registry['env'] = {
46
47
    "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080",
    "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
48
}
49
50
```

51
GitLab 11.6 and newer will attempt to use HTTP Basic
52
53
54
Authentication when a username and password is included in the proxy
URL. Older GitLab versions will omit the authentication details.

55
Proxy settings use the `.` syntax for globing.
56

57
Proxy URL values should generally be `http://` only, unless
58
59
60
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`.
Adam Mulvany's avatar
Adam Mulvany committed
61

62
63
64
65
66
## Applying the changes

Any change made to the environment variables **requires a hard restart** after
reconfigure for it to take effect.

67
NOTE:
68
During a hard restart, your GitLab instance will be down until the
69
70
services are back up.

71
Perform a reconfigure:
72
73
74
75

```shell
sudo gitlab-ctl reconfigure
```