Geo: Use the remote Host in Absolute URLs generated by the primary during proxied requests
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=339262) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=339262) </details> <!--IssueSummary end--> ## Problem Absolute URLs are produced in Rails, using `external_url`. Many of these items fundamentally cannot be [replaced with a relative URL](https://gitlab.com/gitlab-org/gitlab/-/issues/341357). These absolute URLs are used to: - Display the Git clone URL in UI - Tell Runners what [Git URL to clone for that job](https://gitlab.com/gitlab-org/gitlab/-/blob/9bde83896e4c9856a2aea73f15acf20899dac66e/app/models/ci/build.rb#L647) - Produce links in emails - Display the path of image URLs in package registry - Produce links in search results - Produce URLs in GitLab API responses - and more If a secondary site has a different `external_url` than the primary site, then a user of the secondary site will sometimes land on the primary site. This is confusing, and loses the benefit of any "acceleration" by the secondary site. ## Proposal - [ ] Absolute URLs rendered in the UI or by the API should use the same Host that the originating request uses. - [ ] SSH port is customizable per site. Secondary sites with separate URLs may need to send that information to the primary so the primary can properly render SSH clone URLs. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/111328 ### Tasks * Investigate places where the new helper needs to be used * Modify all places that refer to a resource like Git, Packages etc and make sure it uses the new Geo aware URL helper code * Investigate how to expose to Rails that Geo is being proxied * Create some helpers to craft URLs for Geo related resources considering Primary / Secondary and Proxied state ## Open questions What to do about URLs in emails that are generated in the background? There is no "remote Host" in that context. Even when there is a "remote Host" during email generation, one user may cause notifications to be generated for other users. Each user may use a different site. I propose we ignore this problem for now.
issue