New issue
Advanced search Search tips
Starred by 2 users

Issue metadata

Status: Released
Owner: ----
Closed: Apr 2011

Sign in to add a comment

Invalid redirects to change pages when using proxy-https

Reported by, Apr 12 2011

Issue description

Affected Version:

What steps will reproduce the problem?
1. Setup a gerrit review site with listenUrl = proxy-
2. Create a new change and request a review from someone, so they receive an email
3. Click on the link in the email (should be like:

What is the expected output? What do you see instead?

I expect to be taken to,15,n,z which is the correct change page.

Instead, gerrit redirects my browser from to,15,n,z


I use nginx as a reverse proxy and I've added two rewrite lines:

        rewrite ^/([0-9]+)$,$1,n,z;
        rewrite ^/settings$;

        location / {

Comment 1 by, Apr 12 2011

Status: AwaitingInformation
Did you set gerrit.canonicalWebUrl ?

With proxy-http or proxy-https, the frontend web server should be setting the x-forwarded-for/host/server headers so the Jetty container knows how to format the servlet request correctly. It looks like nginx doesn't do that for proxy_pass by default.
I do have gerrit.canonicalWebUrl set, but you're right, nginx wasn't supplying the right headers.

Thanks to this post on the mailing list:

I now have a working nginx config:

        location / {
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;

(I'm not sure the X-Real-IP header is needed but the other two are.)

Would it be worth documenting this? (I'm happy to contribute a patch.) If so, what about renaming this page to just "Reverse Proxy":

and then having "Apache 2 Configuration" and "Nginx Configuration" headings?

Comment 3 by, Apr 13 2011

Status: Accepted
Yes, that sounds like a good idea. Please send a change for review to update the docs.

Comment 4 by, Apr 13 2011

Labels: FixedIn-2.1.7
Status: Submitted

Comment 5 by, May 31 2011

Status: Released

Sign in to add a comment