Geo: Use the remote Host in Absolute URLs generated by the primary during proxied requests
Problem
Absolute URLs are produced in Rails, using external_url
. Many of these items fundamentally cannot be replaced with a relative URL. These absolute URLs are used to:
- Display the Git clone URL in UI
- Tell Runners what Git URL to clone for that job
- 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 !111328 (merged)
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.
Edited by Michael Kozono