My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 905: Invalid redirects to change pages when using proxy-https
2 people starred this issue and may be notified of changes. Back to list
Status:  Released
Owner:  ----
Closed:  Apr 2011


Sign in to add a comment
 
Reported by francoisatwork@gmail.com, Apr 11, 2011
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;
        }
Apr 12, 2011
#1 sop@google.com
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.
Status: AwaitingInformation
Apr 12, 2011
#2 francoisatwork@gmail.com
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?
Apr 12, 2011
#3 sop@google.com
Yes, that sounds like a good idea. Please send a change for review to update the docs.
Status: Accepted
Apr 13, 2011
#4 sop@google.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.1.7
May 31, 2011
#5 sop@google.com
(No comment was entered for this change.)
Status: Released
Sign in to add a comment

Powered by Google Project Hosting