Skip to content

Commit d5d8af0

Browse files
axilleaseread
authored andcommitted
Verify the accuracy of the settings page
1 parent b461ada commit d5d8af0

File tree

1 file changed

+130
-61
lines changed

1 file changed

+130
-61
lines changed

doc/settings/configuration.md

Lines changed: 130 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,36 @@ If you have any issues, see the [troubleshooting section](#relative-url-troubles
119119
Linux package installations load all configuration from `/etc/gitlab/gitlab.rb` file.
120120
This file has strict file permissions and is owned by the `root` user. The reason for strict permissions
121121
and ownership is that `/etc/gitlab/gitlab.rb` is being executed as Ruby code by the `root` user during `gitlab-ctl reconfigure`. This means
122-
that users who have to write access to `/etc/gitlab/gitlab.rb` can add a configuration that is executed as code by `root`.
122+
that users who have write access to `/etc/gitlab/gitlab.rb` can add a configuration that is executed as code by `root`.
123123

124124
In certain organizations, it is allowed to have access to the configuration files but not as the root user.
125125
You can include an external configuration file inside `/etc/gitlab/gitlab.rb` by specifying the path to the file:
126126

127-
```ruby
128-
from_file "/home/admin/external_gitlab.rb"
129-
```
127+
1. Edit `/etc/gitlab/gitlab.rb`:
128+
129+
```ruby
130+
from_file "/home/admin/external_gitlab.rb"
131+
```
130132

131-
Code you include into `/etc/gitlab/gitlab.rb` using `from_file` runs with `root` privileges when you run `sudo gitlab-ctl reconfigure`.
132-
Any configuration that is set in `/etc/gitlab/gitlab.rb` after `from_file` is included, takes precedence over the configuration from the included file.
133+
1. Reconfigure GitLab:
134+
135+
```shell
136+
sudo gitlab-ctl reconfigure
137+
```
138+
139+
When you use `from_file`:
140+
141+
- Code you include into `/etc/gitlab/gitlab.rb` using `from_file` runs with
142+
`root` privileges when you reconfigure GitLab.
143+
- Any configuration that is set in `/etc/gitlab/gitlab.rb` after `from_file` is
144+
included, takes precedence over the configuration from the included file.
133145

134146
## Read certificate from file
135147

136148
Certificates can be stored as separate files and loaded into memory when running `sudo gitlab-ctl reconfigure`. Files containing
137149
certificates must be plaintext.
138150

139-
In this example, the PostgreSQL server certificate is read directly from a file rather than copy and pasting into the `gitlab.rb` directly.
151+
In this example, the [PostgreSQL server certificate](database.md#configuring-ssl) is read directly from a file rather than copying and pasting into `/etc/gitlab/gitlab.rb` directly.
140152

141153
```ruby
142154
postgresql['internal_certificate'] = File.read('/path/to/server.crt')
@@ -219,14 +231,14 @@ endpoint and specify the `repository_storage` attribute.
219231

220232
## Change the name of the Git user or group
221233

222-
NOTE:
234+
WARNING:
223235
We do not recommend changing the user or group of an existing installation because it can cause unpredictable side effects.
224236

225237
By default, Linux package installations use the user name `git` for Git GitLab Shell login,
226238
ownership of the Git data itself, and SSH URL generation on the web interface.
227239
Similarly, the `git` group is used for group ownership of the Git data.
228240

229-
To change the user and group:
241+
To change the user and group on a new Linux package installation:
230242

231243
1. Edit `/etc/gitlab/gitlab.rb`:
232244

@@ -243,14 +255,27 @@ To change the user and group:
243255

244256
If you are changing the username of an existing installation, the reconfigure run
245257
doesn't change the ownership of the nested directories, so you must do that manually.
246-
Make sure that the new user can access the `repositories` and `uploads` directories.
258+
259+
At the very least, you must change ownership of the repositories and uploads
260+
directories:
261+
262+
```shell
263+
sudo chown -R gitlab:gitlab /var/opt/gitlab/git-data/repositories
264+
sudo chown -R gitlab:gitlab /var/opt/gitlab/gitlab-rails/uploads
265+
```
247266
248267
## Specify numeric user and group identifiers
249268
250269
Linux package installations create users for GitLab, PostgreSQL, Redis, NGINX, etc. To
251270
specify the numeric identifiers for these users:
252271
253-
1. Edit `/etc/gitlab/gitlab.rb`:
272+
1. Write down the old user and group identifiers, as you might need them later:
273+
274+
```shell
275+
sudo cat /etc/passwd
276+
```
277+
278+
1. Edit `/etc/gitlab/gitlab.rb` and change any of the identifiers you want:
254279
255280
```ruby
256281
user['uid'] = 1234
@@ -269,21 +294,23 @@ specify the numeric identifiers for these users:
269294
prometheus['gid'] = 1240
270295
```
271296
272-
1. Reconfigure GitLab:
297+
1. Stop, reconfigure, and then start GitLab:
273298
274299
```shell
300+
sudo gitlab-ctl stop
275301
sudo gitlab-ctl reconfigure
302+
sudo gitlab-ctl start
276303
```
277304
278305
1. Optional. If you're changing `user['uid']` and `user['gid']`, make sure to update the uid/guid of any files not managed by the Linux package
279306
directly, for example, the logs:
280307

281-
```shell
282-
find /var/log/gitlab -uid <old_uid> | xargs -I:: chown git ::
283-
find /var/log/gitlab -gid <old_uid> | xargs -I:: chgrp git ::
284-
find /var/opt/gitlab -uid <old_uid> | xargs -I:: chown git ::
285-
find /var/opt/gitlab -gid <old_uid> | xargs -I:: chgrp git ::
286-
```
308+
```shell
309+
find /var/log/gitlab -uid <old_uid> | xargs -I:: chown git ::
310+
find /var/log/gitlab -gid <old_uid> | xargs -I:: chgrp git ::
311+
find /var/opt/gitlab -uid <old_uid> | xargs -I:: chown git ::
312+
find /var/opt/gitlab -gid <old_uid> | xargs -I:: chgrp git ::
313+
```
287314

288315
## Disable user and group account management
289316

@@ -296,16 +323,16 @@ might need to disable account management done by the GitLab package.
296323
297324
By default, the Linux package installations expect the following users and groups to exist:
298325
299-
| Linux user and group | Required | Description |
300-
| -------------------- | --------------------------------------- | -------------------------------------------------------------------- |
301-
| `git` | Yes | GitLab user/group |
302-
| `gitlab-www` | Yes | Web server user/group |
303-
| `gitlab-redis` | Only when using the packaged Redis | Redis user/group for GitLab |
304-
| `gitlab-psql` | Only when using the packaged PostgreSQL | PostgreSQL user/group |
305-
| `gitlab-prometheus` | Yes | Prometheus user/group for Prometheus monitoring and various exporters|
306-
| `mattermost` | Only when using GitLab Mattermost | GitLab Mattermost user/group |
307-
| `registry` | Only when using GitLab Registry | GitLab Registry user/group |
308-
| `gitlab-consul` | Only when using GitLab Consul | GitLab Consul user/group |
326+
| Linux user and group | Required | Description | Default home directory | Default shell |
327+
| -------------------- | --------------------------------------- | --------------------------------------------------------------------- | ---------------------------- | ------------- |
328+
| `git` | Yes | GitLab user/group | `/var/opt/gitlab` | `bin/sh` |
329+
| `gitlab-www` | Yes | Web server user/group | `/var/opt/gitlab/nginx` | `/bin/false` |
330+
| `gitlab-prometheus` | Yes | Prometheus user/group for Prometheus monitoring and various exporters | `/var/opt/gitlab/prometheus` | `/bin/sh` |
331+
| `gitlab-redis` | Only when using the packaged Redis | Redis user/group for GitLab | `/var/opt/gitlab/redis` | `/bin/false` |
332+
| `gitlab-psql` | Only when using the packaged PostgreSQL | PostgreSQL user/group | `/var/opt/gitlab/postgresql` | `/bin/sh` |
333+
| `gitlab-consul` | Only when using GitLab Consul | GitLab Consul user/group | `/var/opt/gitlab/consul` | `/bin/sh` |
334+
| `registry` | Only when using GitLab Registry | GitLab Registry user/group | `/var/opt/gitlab/registry` | `/bin/sh` |
335+
| `mattermost` | Only when using GitLab Mattermost | GitLab Mattermost user/group | `/var/opt/gitlab/mattermost` | `/bin/sh` |
309336
310337
To disable user and group accounts management:
311338
@@ -319,8 +346,8 @@ To disable user and group accounts management:
319346
320347
```ruby
321348
# GitLab
322-
user['username'] = "custom-gitlab"
323-
user['group'] = "custom-gitlab"
349+
user['username'] = "git"
350+
user['group'] = "git"
324351
user['shell'] = "/bin/sh"
325352
user['home'] = "/var/opt/custom-gitlab"
326353
@@ -330,19 +357,38 @@ To disable user and group accounts management:
330357
web_server['shell'] = '/bin/false'
331358
web_server['home'] = '/var/opt/gitlab/webserver'
332359
333-
# Postgresql (not needed when using external Postgresql)
334-
postgresql['username'] = "postgres-gitlab"
335-
postgresql['group'] = "postgres-gitlab"
336-
postgresql['shell'] = "/bin/sh"
337-
postgresql['home'] = "/var/opt/postgres-gitlab"
360+
# Prometheus
361+
prometheus['username'] = 'gitlab-prometheus'
362+
prometheus['group'] = 'gitlab-prometheus'
363+
prometheus['shell'] = '/bin/sh'
364+
prometheus['home'] = '/var/opt/gitlab/prometheus'
338365
339366
# Redis (not needed when using external Redis)
340367
redis['username'] = "redis-gitlab"
341368
redis['group'] = "redis-gitlab"
342369
redis['shell'] = "/bin/false"
343370
redis['home'] = "/var/opt/redis-gitlab"
344371
345-
# And so on for users/groups for GitLab Mattermost
372+
# Postgresql (not needed when using external Postgresql)
373+
postgresql['username'] = "postgres-gitlab"
374+
postgresql['group'] = "postgres-gitlab"
375+
postgresql['shell'] = "/bin/sh"
376+
postgresql['home'] = "/var/opt/postgres-gitlab"
377+
378+
# Consul
379+
consul['username'] = 'gitlab-consul'
380+
consul['group'] = 'gitlab-consul'
381+
consul['dir'] = "/var/opt/gitlab/registry"
382+
383+
# Registry
384+
registry['username'] = "registry"
385+
registry['group'] = "registry"
386+
registry['dir'] = "/var/opt/gitlab/registry"
387+
388+
# Mattermost
389+
mattermost['username'] = 'mattermost'
390+
mattermost['group'] = 'mattermost'
391+
mattermost['home'] = '/var/opt/gitlab/mattermost'
346392
```
347393
348394
1. Reconfigure GitLab:
@@ -363,7 +409,7 @@ To move an existing home directory, GitLab services need to be stopped and some
363409
1. Stop GitLab:
364410
365411
```shell
366-
gitlab-ctl stop
412+
sudo gitlab-ctl stop
367413
```
368414
369415
1. Stop the runit server:
@@ -375,7 +421,7 @@ To move an existing home directory, GitLab services need to be stopped and some
375421
1. Change the home directory:
376422
377423
```shell
378-
usermod -d /path/to/home <username>
424+
sudo usermod -d /path/to/home <username>
379425
```
380426
381427
If you had existing data, you need to manually copy/rsync it to the new location:
@@ -473,7 +519,8 @@ To disable the management of storage directories:
473519
## Start Linux package installation services only after a given file system is mounted
474520
475521
If you want to prevent Linux package installation services (NGINX, Redis, Puma, etc.)
476-
from starting before a given file system is mounted:
522+
from starting before a given file system is mounted, you can set the
523+
`high_availability['mountpoint']` setting:
477524
478525
1. Edit `/etc/gitlab/gitlab.rb`:
479526
@@ -488,6 +535,9 @@ from starting before a given file system is mounted:
488535
sudo gitlab-ctl reconfigure
489536
```
490537
538+
NOTE:
539+
If the mount point doesn't exist, GitLab fails to reconfigure.
540+
491541
## Configure the runtime directory
492542

493543
When Prometheus monitoring is enabled, the GitLab Exporter conducts measurements
@@ -522,8 +572,22 @@ To enable the Rails metrics again:
522572

523573
## Configure a failed authentication ban
524574

525-
You can configure a [failed authentication ban](https://docs.gitlab.com/ee/security/rate_limits.html#failed-authentication-ban-for-git-and-container-registry)
526-
for Git and the container registry:
575+
You can configure a
576+
[failed authentication ban](https://docs.gitlab.com/ee/security/rate_limits.html#failed-authentication-ban-for-git-and-container-registry)
577+
for Git and the container registry. When a client is banned, a 403 error code
578+
is returned.
579+
580+
The following settings can be configured:
581+
582+
| Setting | Description |
583+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
584+
| `enabled` | `false` by default. Set this to `true` to enable the Git and registry authentication ban. |
585+
| `ip_whitelist` | IPs to not block. They must be formatted as strings in a Ruby array. You can use either single IPs or CIDR notation, for example, `["127.0.0.1", "127.0.0.2", "127.0.0.3", "192.168.0.1/24"]`. |
586+
| `maxretry` | The maximum amount of times a request can be made in the specified time. |
587+
| `findtime` | The maximum amount of time in seconds that failed requests can count against an IP before it's added to the denylist. |
588+
| `bantime` | The total amount of time in seconds that an IP is blocked. |
589+
590+
To configure the Git and container registry authentication ban:
527591
528592
1. Edit `/etc/gitlab/gitlab.rb`:
529593
@@ -543,18 +607,6 @@ for Git and the container registry:
543607
sudo gitlab-ctl reconfigure
544608
```
545609
546-
The following settings can be configured:
547-
548-
- `enabled`: By default, this is set to `false`. Set this to `true` to enable Rack Attack.
549-
- `ip_whitelist`: IPs to not block. They must be formatted as strings in a
550-
Ruby array. CIDR notation is supported in GitLab 12.1 and later.
551-
For example, `["127.0.0.1", "127.0.0.2", "127.0.0.3", "192.168.0.1/24"]`.
552-
- `maxretry`: The maximum amount of times a request can be made in the
553-
specified time.
554-
- `findtime`: The maximum amount of time that failed requests can count against an IP
555-
before it's added to the denylist (in seconds).
556-
- `bantime`: The total amount of time that an IP is blocked (in seconds).
557-
558610
## Disable automatic cache cleaning during installation
559611
560612
If you have a large GitLab installation, you might not want to run a `rake cache:clear` task
@@ -579,22 +631,27 @@ To disable automatic cache cleaning during installation:
579631
580632
## Error Reporting and Logging with Sentry
581633
582-
[Sentry](https://sentry.io) is an error reporting and logging tool which can be
583-
used as SaaS or on-premise. It's Open Source, and you can
584-
[browse its source code repositories](https://github.com/getsentry).
585-
586634
WARNING:
587-
From GitLab 17.0, only Sentry versions 21.5.0 or later will be supported. If you use an earlier version of a Sentry instance that you host, you must
588-
[upgrade Sentry](https://develop.sentry.dev/self-hosted/releases/) to continue collecting errors from your GitLab environments.
635+
From GitLab 17.0, only Sentry versions 21.5.0 or later will be supported. If
636+
you use an earlier version of a Sentry instance that you host, you must
637+
[upgrade Sentry](https://develop.sentry.dev/self-hosted/releases/) to continue
638+
collecting errors from your GitLab environments.
639+
640+
Sentry is an open source error reporting and logging tool which can be used as
641+
SaaS (<https://sentry.io>) or [host it yourself](https://develop.sentry.dev/self-hosted/).
589642
590643
To configure Sentry:
591644
645+
1. Create a project in Sentry.
646+
1. Find the
647+
[Data Source Name (DSN)](https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/)
648+
of the project you created.
592649
1. Edit `/etc/gitlab/gitlab.rb`:
593650
594651
```ruby
595652
gitlab_rails['sentry_enabled'] = true
596-
gitlab_rails['sentry_dsn'] = 'https://<key>@sentry.io/<project>'
597-
gitlab_rails['sentry_clientside_dsn'] = 'https://<key>@sentry.io/<project>'
653+
gitlab_rails['sentry_dsn'] = 'https://<public_key>@<host>/<project_id>' # value used by the Rails SDK
654+
gitlab_rails['sentry_clientside_dsn'] = 'https://<public_key>@<host>/<project_id>' # value used by the Browser JavaScript SDK
598655
gitlab_rails['sentry_environment'] = 'production'
599656
```
600657
@@ -927,3 +984,15 @@ Ran ["usermod", "-d", "/var/opt/gitlab", "git"] returned 8
927984
```
928985

929986
Make sure to stop `runit` before moving the home directory.
987+
988+
### GitLab responds with 502 after changing the name of the Git user or group
989+
990+
If you changed the [name of the Git user or group](#change-the-name-of-the-git-user-or-group)
991+
on an existing installation, this can cause many side effects.
992+
993+
You can check for errors that relate to files unable to access and try to
994+
fix their permissions:
995+
996+
```shell
997+
gitlab gitlab-ctl tail -f
998+
```

0 commit comments

Comments
 (0)