Health check does not work when gitlab_rails[allowed_hosts] set

Summary

When next options provided, the gitlab-healthcheck-rc should not query localhost, but query allowed_hosts

Steps to reproduce

    external_url "http://office.black-list.info/gitlab"
    gitlab_rails['allowed_hosts'] = ['office.black-list.info']

What is the current bug behavior?

    # cat /opt/gitlab/etc/gitlab-healthcheck-rc
    url='http://localhost:80/gitlab/help'
    flags='--insecure'

image

What is the expected correct behavior?

    # cat /opt/gitlab/etc/gitlab-healthcheck-rc
    url='http://office.black-list.info:80/gitlab/help'
    flags='--insecure'

image

Relevant logs and/or screenshots

127.0.0.1 - - [04/Jun/2022:23:30:15 +0000] "GET /gitlab/help HTTP/1.1" 403 4950 "" "curl/7.79.1-DEV" -

Output of checks

What is the command to check this?

Results of GitLab environment info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.7.5p203
Gem Version:	3.1.4
Bundler Version:2.2.33
Rake Version:	13.0.6
Redis Version:	6.2.6
Sidekiq Version:6.4.0
Go Version:	unknown

GitLab information
Version:	15.0.1
Revision:	39b217000de
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.6
URL:		http://office.black-list.info/gitlab
HTTP Clone URL:	http://office.black-list.info/gitlab/some-group/some-project.git
SSH Clone URL:	git@office.black-list.info:some-group/some-project.git
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	14.3.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.3.0 ? ... OK (14.3.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.5) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Edited by Jason Plum