URLs for files in repos not working over SSH tunnel/bastion

Summary

Our gitlab-ee core install (version 13.0.3) is hosted in a container that is behind a bastion. The IP of the gitlab container is 10.0.0.50, and external_url is set to this IP. Users access the gitlab instance by setting up an SSH tunnel such that localhost:9000 forwards to 10.0.0.50.

This works well -- with one exception, that URLs that point to file assets in the repo have a path like http://10.0.0.50/server/reponame/-/blob/master/testing.sh, which the users can't reach on their machines since they are outside that network. The URL should say http://localhost:9000/server/reponame/-/blob/master/testing.sh -- like all the links in the left menu (http://localhost:9000/server/reponame/activity for instance).

Browsing into folders works fine -- but these URLs are also incorrect (http://10.0.0.50/server/reponame/-/tree/master/foldername).

Not sure if this is expected behavior or not -- but it used to work (I can't recall which version change caused this, may have been in the 12.x series where I first saw it).

Steps to reproduce

Setup network topology as described above, try to access a file asset in any repo and the link will contain a URL that can't be reached.

What is the current bug behavior?

Links to files in the repo are broken when hosted over an ssh tunnel/bastion

What is the expected correct behavior?

URLs should be reachable (localhost:9000 in the example above)

Relevant logs and/or screenshots

Screen_Shot_2020-06-03_at_11.30.03_AM

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		Ubuntu 18.04
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.6.6p146
Gem Version:	2.7.10
Bundler Version:1.17.3
Rake Version:	12.3.3
Redis Version:	5.0.9
Git Version:	2.26.2
Sidekiq Version:5.2.7
Go Version:	unknown

GitLab information
Version:	13.0.3-ee
Revision:	d27df234886
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	11.7
URL:		http://10.0.0.50
HTTP Clone URL:	http://10.0.0.50/some-group/some-project.git
SSH Clone URL:	git@10.0.0.50:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: 

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

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 >= 13.2.0 ? ... OK (13.2.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 ... 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 ...

Git configured correctly? ... yes 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) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 3/5 ... yes 3/6 ... yes 3/8 ... yes 11/10 ... yes 11/11 ... yes 3/12 ... yes 18/13 ... yes 18/14 ... yes 18/16 ... yes 18/18 ... yes 18/19 ... yes 18/20 ... yes 18/21 ... yes 18/22 ... yes 18/23 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.6) Git version >= 2.22.0 ? ... yes (2.26.2) Git user has default SSH configuration? ... yes Active users: ... 19 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... no Try fixing it: Please migrate all projects to hashed storage as legacy storage is deprecated in 13.0 and support will be removed in 14.0. For more information see: doc/administration/repository_storage_types.md Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Matt Wiebold