Background: We have a Gitlab instance running, which is reachable over 2 different domains from 2 different networks (that is mandated by the network structure and cannot be changed). Gitlab supports only 1 domain. In the past it worked out of the box, but with the last update the links to the files in a repository are set to the main domain, even when coming from the second domain. So we are able to browse the Gitlab UI through the second domain flawlessly. But as we click on a file in a repository, the domain changes from the second to the main domain (which isn't reachable from the second network), because the links for the files are absolut URLs with the main domain. This means, that we cannot open a file in the Gitlab Web UI from the second domain. The problem is only, that these are absolute links with the wrong domain. With changing the domain by hand we can still display the files.
The Gitlab Support stated, that it is not supported by Gitlab itself, but it should be possible to configure Nginx (which is used by Gitlab) to rewrite the URLs depending on the requesting domain. I couldn't find corresponding results, when search on the web (only about rewriting requested URLs, not the links on the site).
To further describe the structure of the problem, please look at this diagram:
The single Gitlab server is reachable over 2 individual loadbalancers (which act here as routers, since they only point to that one server). They are reachable under their own domain (maindomain.com
and seconddomain.com
respectively) and only through their own network. The Gitlab instance is configured for the maindomain.com
domain and cannot directly be configured for a second domain. The problem described above arises when trying to open a file in the web UI while being connected through the second network and seconddomain.com
. All that is embedded into the organizational networks and is not reachable from the internet.
TL;DR: Is it possible to let Nginx rewrite absolute URLs in links on a served website depending on the requesting URL of the website? If yes, how can it be done?
0 Answers