commit | 78066fc41cacd0552e23366f492712c9b941fdf7 | [log] [tgz] |
---|---|---|
author | Luca Milanesio <luca.milanesio@gmail.com> | Fri Apr 19 17:14:39 2024 +0100 |
committer | Luca Milanesio <luca.milanesio@gmail.com> | Fri Apr 19 21:05:52 2024 +0100 |
tree | e63c5af05ec0cd309a790c8590410ed5748e5584 | |
parent | bd7602523971487416a4e987a0925f8a57ebfbe0 [diff] |
Do not get HttpServletRequest in SSH and SendMail threads When asking for the canonical web url in a SSH or SendMail thread it isn't useful to request the HttpServletRequest and cause Guice exceptions: it is way better to just give up and accept the default behaviour in Gerrit. Also, when the HttpServletRequest cannot be obtained the Guice exception to manage is ProvisionException. Change-Id: Ife5f71285a91c95b161aeb2ce4684ba2261d1aa6
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 = ^.*