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. Some of these fundamentally cannot be replaced with a relative URL. These are used for example 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
If a user is using a Geo secondary (which is proxying to the primary), then as a result of the above items, they can end up on directly on the Geo primary. Thus losing the benefit of any "acceleration" by the Geo secondary.
Note: The "different URL" use-case is far less valuable than "unified URL", and does not need to block it.
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?
It's not obvious, since a user may cause notifications to be generated for other users. Other users may use different secondaries or use the primary. I propose we ignore this problem, since using the remote Host will be preferred most of the time. Then, if someone finds a problem with that behavior, we can e.g. iterate on the behavior of that specific email.