doc/administration/geo/replication/location_aware_git_url.md
{{< details >}}
{{< /details >}}
[!note] GitLab Geo supports location-aware DNS including web UI and API traffic. This configuration is recommended over the location-aware Git remote URL described in this document.
You can provide GitLab users with a single remote URL that automatically uses the Geo site closest to them. This means users don't need to update their Git configuration to take advantage of closer Geo sites as they move.
This is possible because, Git push requests can be automatically redirected (HTTP) or proxied (SSH) from secondary sites to the primary site.
Though these instructions use AWS Route53, other services such as Cloudflare could be used as well.
In this example, we have already set up:
primary.example.com as a Geo primary site.secondary.example.com as a Geo secondary site.We create a git.example.com subdomain that automatically directs
requests:
In any case, you require:
If you haven't yet set up a Geo primary site and secondary site, see the Geo setup instructions.
In a Route53 Hosted Zone, traffic policies can be used to set up a variety of routing configurations.
Go to the Route53 dashboard and select Traffic policies.
Select Create traffic policy.
Fill in the Policy Name field with Single Git Host and select Next.
Leave DNS type as A: IP Address in IPv4 format.
Select Connect to and select Geolocation rule.
For the first Location, leave it as Default.
Select Connect to and select New endpoint.
Choose Type value and fill it in with <your **primary** IP address>.
For the second Location, choose Europe.
Select Connect to and select New endpoint.
Choose Type value and fill it in with <your **secondary** IP address>.
Select Create traffic policy.
Fill in Policy record DNS name with git.
Select Create policy records.
You have successfully set up a single host, for example, git.example.com which
distributes traffic to your Geo sites by geolocation!
When a user clones a repository for the first time, they typically copy the Git remote URL from the project page. By default, these SSH and HTTP URLs are based on the external URL of the current host. For example:
[email protected]:group1/project1.githttps://secondary.example.com/group1/project1.gitYou can customize the:
git.example.com. To do so, change the SSH remote URL
host by setting gitlab_rails['gitlab_ssh_host'] in gitlab.rb of web nodes.After following the configuration steps documented previously, handling for Git requests is now location aware. For requests:
git clone http://git.example.com/foo/bar.git is directed to the secondary site.git push is initially directed to the secondary, which automatically
redirects to primary.example.com.git clone [email protected]:foo/bar.git is directed to the secondary.git push is initially directed to the secondary, which automatically
proxies the request to primary.example.com.