I have a pretty "standard" Gerrit setup on a Debian 11 VM:
/opt/gerrit/
with a specific gerrit
user used to execute the software; this user have the correct rights to access the path; also the configuration is very basic[gerrit]
basePath = /opt/git
canonicalWebUrl = http://192.168.10.101/git/
serverId = xxxxx
[container]
javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = gerrit
javaHome = /usr/lib/jvm/java-11-openjdk-amd64
[index]
type = lucene
[auth]
type = LDAP
gitBasicAuthPolicy = LDAP
[ldap]
...
[receive]
enableSignedPush = true
[sendemail]
...
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = proxy-http://127.0.0.1:8080/git/
[cache]
directory = cache
listen 80;
server_name git.mysite.com;
location ^~ /git/ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
The setup works as expected, I was trying to add some customization to the login page but I've found an error that I can't quite narrow down. I've added a simple "GerritSiteHeader.html" page, defined as:
<div>
<img src="static/logo.png" height="150" width="415"/>
</div>
The "logo.png" is stored under /opt/gerrit/static/ with permission assigned to "gerrit" user.
When I access the login page from http://192.168.10.101/git/login
, the logo is correclty loaded, but if instead I'm using an URL like http://192.168.10.101/git/login/
(with the added '/' at the end, which happens e.g. when clicking "Sign in" link inside gerrit, for example git/login/%2F%2Fq%2Fstatus%3Aopen%2B-is%3Awip
), the logo is not displayed, from browser console I see "Error 401 Unauthorized"
I've checked the configurations of nginx and proxy pass but I haven't found anything, I'm not used to this kind of configuration. For what I see the main difference from browser console is that with git/login/
URL, there are two GET request, referring to "login" and the logo.png itself, using instead git/login
triggers only one GET request to "login" only.
Any help or suggestions are appreciated, even by only pointing to more documentation or information! Grazie :)
Found the solution by trial and error. Apparently there is something going on between nginx and Gerrit with the resolution of the URL, I've solved this by specifing a full path to my logo:
<img src="/git/static/logo.png" height="150" width="415"/>
This allows the correct loading of the image independetly from the URL used