Skip to content

Commit b86ec6b

Browse files
balasankarcAnton SmithereadKenneth Chu
committed
Merge branch 'docs/add-reverse-proxy-advice-nginx' into 'master'
Add details for using NGINX as reverse proxy See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/6928 Merged-by: Balasankar 'Balu' C <[email protected]> Approved-by: João Alexandre Cunha <[email protected]> Approved-by: Evan Read <[email protected]> Approved-by: Balasankar 'Balu' C <[email protected]> Reviewed-by: Evan Read <[email protected]> Co-authored-by: Anton Smith <[email protected]> Co-authored-by: Evan Read <[email protected]> Co-authored-by: Kenneth Chu <[email protected]>
2 parents eb8ddc9 + b1439b7 commit b86ec6b

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

doc/settings/nginx.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,30 @@ existing server blocks, you can use the following setting.
351351

352352
```ruby
353353
# Example: include a directory to scan for additional config files
354-
nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/*.conf;"
354+
nginx['custom_nginx_config'] = "include /etc/gitlab/nginx/sites-enabled/*.conf;"
355355
```
356356

357+
You should create custom server blocks in the `/etc/gitlab/nginx/sites-available` directory. To enable them, symlink them into the
358+
`/etc/gitlab/nginx/sites-enabled` directory:
359+
360+
1. Create the `/etc/gitlab/nginx/sites-enabled` directory.
361+
1. Run the following command:
362+
363+
```shell
364+
sudo ln -s /etc/gitlab/nginx/sites-available/example.conf /etc/gitlab/nginx/sites-enabled/example.conf
365+
```
366+
367+
You can add domains for server blocks [as an alternative name](ssl/index.md#add-alternative-domains-to-the-certificate)
368+
to the generated Let's Encrypt SSL certificate.
369+
357370
Run `gitlab-ctl reconfigure` to rewrite the NGINX configuration and restart
358-
NGINX.
371+
NGINX. You must reload NGINX (`gitlab-ctl hup nginx`) or restart NGINX (`gitlab-ctl restart nginx`) whenever you make changes to the custom server blocks.
359372

360373
This inserts the defined string into the end of the `http` block of
361374
`/var/opt/gitlab/nginx/conf/nginx.conf`.
362375

363-
Consider including your custom NGINX configuration file in `/etc/gitlab/` so the custom configuration is backed up.
376+
Custom NGINX settings inside the `/etc/gitlab/` directory are backed up to `/etc/gitlab/config_backup/`
377+
during an upgrade and when `sudo gitlab-ctl backup-etc` is manually executed.
364378

365379
## Custom error pages
366380

doc/settings/ssl/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,35 @@ To configure GitLab to use a custom ACME server:
169169
sudo gitlab-ctl reconfigure
170170
```
171171

172+
### Add alternative domains to the certificate
173+
174+
You can add alternative domains (or subject alternative names) to the Let's Encrypt certificate.
175+
This can be helpful if you would like to use the [bundled NGINX](../nginx.md) as a
176+
[reverse proxy for other backend applications](../nginx.md#inserting-custom-settings-into-the-nginx-configuration).
177+
178+
The DNS records for the alternative domains must point to the GitLab instance.
179+
180+
To add alternative domains to your Let's Encrypt certificate:
181+
182+
1. Edit `/etc/gitlab/gitlab.rb` and add the alternative domains:
183+
184+
```ruby
185+
# Separate multiple domains with commas
186+
letsencrypt['alt_names'] = ['another-application.example.com']
187+
```
188+
189+
1. Reconfigure GitLab:
190+
191+
```shell
192+
sudo gitlab-ctl reconfigure
193+
```
194+
195+
The resulting Let's Encrypt certificates generated for the main GitLab application will
196+
include the alternative domains specified. The generated files are located at:
197+
198+
- `/etc/gitlab/ssl/gitlab.example.com.key` for the key.
199+
- `/etc/gitlab/ssl/gitlab.example.com.crt` for the certificate.
200+
172201
## Configure HTTPS manually
173202
174203
WARNING:

files/gitlab-config-template/gitlab.rb.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,7 @@ external_url 'GENERATED_EXTERNAL_URL'
27022702
# letsencrypt['auto_renew_minute'] = nil # Should be a number or cron expression, if specified.
27032703
# letsencrypt['auto_renew_day_of_month'] = "*/4"
27042704
# letsencrypt['auto_renew_log_directory'] = '/var/log/gitlab/lets-encrypt'
2705+
# letsencrypt['alt_names'] = []
27052706

27062707
##! Turn off automatic init system detection. To skip init detection in
27072708
##! non-docker containers. Recommended not to change.

0 commit comments

Comments
 (0)