commit | f94abd64a288e5c25adee4d3e88bf79990f77c5b | [log] [tgz] |
---|---|---|
author | Dariusz Luksza <dariusz.luksza@gmail.com> | Sat Nov 25 08:34:53 2023 +0000 |
committer | Dariusz Luksza <dariusz.luksza@gmail.com> | Wed Mar 20 12:18:26 2024 +0000 |
tree | af44316bfd01d6450b421869bfb27fa40d5ede83 | |
parent | ce5c1b55a07fe09307c85869b94fe16d3acc3969 [diff] |
Provide virtual host name in git command outputs When pushing changes to Gerrit, the URL for each of them will be returned in the push command output. Previously those URLs used the name of the main host. To fix this, `VirtualHostHttpCanonicalWebUrlProvider` needs to be aware of the optional request provider, so that we can extract the server name from the request processed on a different thread where our `ThreadLocal` was not set. Additionally, it needs to keep its state as a singleton. Bug: Issue 311925527 Change-Id: I8259aa99b9924daea9749a999f2fee81c7bf08ed
Gerrit lib module to split the projects' space into virtual hosts similarly of what you would do with an HTTP Server and different domain names.
Build this module as it was a Gerrit plugin:
virtualhost
directory to Gerrit /plugins/virtualhost
bazel build plugins/virtualhost
virtualhost.jar
module is generated under /bazel-genfiles/plugins/virtualhost/
Copy virtualhost.jar
library to Gerrit /lib
and add the following two extra settings to gerrit.config
:
[gerrit] installModule = com.gerritforge.gerrit.modules.virtualhost.GuiceModule [httpd] filterClass = com.gerritforge.gerrit.modules.virtualhost.VirtualHostFilter
X-Forwarded-Host
Header:When Gerrit is hidden behind multiple service layers (eg. reverse-proxy and load balancer), it is essential to ensure the propagation from the upstream proxy of the header X-Forwarded-Host from the upstream proxy.
/etc/virtualhost.config contains the definition of the virtual hosts and the set of projects included.
Each server
section defines a virtual host and contains a set of projects included. Projects are defined using Gerrit ref-matching expressions and can be repeated multiple times to include multiple matchers.
Example to include all the projects starting with team1/
and the ones starting with the username:
[server "team1.mycompany.com"] projects = team1/* projects = ${username}/*
For all the other server names that are not defined and for SSH access, there is a special default section that lists of visible projects.
Example to include all the projects by default:
[default] projects = ^.*