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 francois...@gmail.com, Apr 12 2011

Issue description

Affected Version: 2.1.6.1

What steps will reproduce the problem?
1. Setup a gerrit review site with listenUrl = proxy-https://127.0.0.1:8081/
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: https://review.example.com/15)

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

I expect to be taken to https://review.example.com/#q,15,n,z which is the correct change page.

Instead, gerrit redirects my browser from https://review.example.com/15 to https://127.0.0.1:8081/#q,15,n,z

Work-around:

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

        rewrite ^/([0-9]+)$ https://review.example.com/#q,$1,n,z;
        rewrite ^/settings$ https://review.example.com/#settings;

        location / {
                proxy_pass   http://127.0.0.1:8081;
        }
 

Comment 1 by sop@google.com, 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:

  http://groups.google.com/group/repo-discuss/browse_thread/thread/a935e3a2b8e6b228?tvc=2

I now have a working nginx config:

        location / {
                proxy_pass   http://127.0.0.1:8081;
                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":

  http://gerrit.googlecode.com/svn/documentation/2.1.6/config-apache2.html

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

Comment 3 by sop@google.com, 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 sop@google.com, Apr 13 2011

Labels: FixedIn-2.1.7
Status: Submitted

Comment 5 by sop@google.com, May 31 2011

Status: Released

Sign in to add a comment