1

After installing Gerrit following Using Gerrit in production section from https://github.com/GerritCodeReview/docker-gerrit, the field was set automatically to this value:

[gerrit]
        canonicalWebUrl = http://eac32ee72f2b/

I want to use Gerrit behind a reverse proxy, so I configured Apache2 like this:

ProxyPass / http://192.168.19.241:8080/ nocanon

This works, but as soon as I set gerrit.canonicalWebUrl to https://gerrit.example.com, I get The page isn’t redirecting properly and the URL in the browser becomes https://gerrit.example.com//login/.

If I try to set the cannonical web url to https://gerrit.example.com/g/ and update Apache2 accordingly to:

ProxyPass /g/ http://192.168.19.241:8080/g/ nocanon

I get "Not found" message in the browser and the URL in the bar now reads https://gerrit.example.com/g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g//g. If I inspect the HTTP headers, for the initial request for page https://gerrit.example.com/g I get a 301 redirect to https://gerrit.example.com/g//g.

In all cases, the configuration httpd.listenUrl was proxy-http://*:8080.

Can anyone tell me what am I doing wrong? I would like to set the proper web URL, because it is visible in the links to checkout repositories over HTTP, and maybe also in other places.

andi
  • 143
  • 1
  • 1
  • 11
  • Have you checked the DNS for gerrit.company.com? I assume company.com is a placeholder for your actual company. –  Dec 29 '17 at 13:44
  • Please use `example.com` when needing dummy names for illustration purposes, not something else madeup. – Patrick Mevzek Dec 29 '17 at 14:25
  • Are Gerrit and Apache2 on the same server or not? – Patrick Mevzek Dec 29 '17 at 14:25
  • @PatrickMevzek I fixed the example.com problem. Currently gerrit is not on the same server as Apache2. In the end I plan to run them on the same server. – andi Dec 29 '17 at 14:38
  • @barrycarter the Gerrit subdomain is not yet registered to point to this server, so for now I hacked c:\windows\system32\etc\hosts. So neither Apache2 nor gerrit will get this if they query DNS. But I have been using like this virtual hosts and all was well. And I think that Gerrit, being behind a firewall, should not query DNS... – andi Dec 29 '17 at 14:46
  • @andi OK, that's what I meant. Since it's a private IP address, I wasn't suggest global DNS-- just something (like /etc/hosts) that makes your browser take you to the correct IP address. Unless I'm missing something, things are working for you when you use the IP address, but not when you use the domain name? –  Dec 29 '17 at 16:13
  • @barrycarter: thanks for the help. After I posted the question I got myself a real domain, and problem persisted. But fixing the listenUrl to `proxy-https` did the trick. It was my fault for not reading properly the documentation. – andi Jan 03 '18 at 11:32

1 Answers1

1

I missed this chapter: https://gerrit-review.googlesource.com/Documentation/config-reverseproxy.html#_ssl

It is written to use proxy-https instead of proxy-http when using HTTPS with Apache2. It all worked with this configuration:

[httpd]
    listenUrl = proxy-https://*:8080/
andi
  • 143
  • 1
  • 1
  • 11