I have a working gerrit installation, the only thing is, gerrit is configured with HTTP authentication backend, and nginx handle the authentication.

Now, I want to use gerrit restapi (just to set Verified label via curl as a specific user). for that I need to use http password generated by gerrit in setting panel. so you can see the problem. there is two different password. first I try to set same password for both, (nginx password is in my control, gerrit is not) then I change try to create a new location for /a/ (gerrit prefix for authentication) and remove the nginx password on that route, yet no luck. the final nginx config is :

location /a/ {
        proxy_set_header  X-Forwarded-For $remote_addr;
        proxy_set_header  Host $host;
        auth_basic "Gerrit";
        proxy_set_header Authorization $http_authorization;
        proxy_pass_header  Authorization;

location / {
        proxy_set_header  X-Forwarded-For $remote_addr;
        proxy_set_header  Host $host;
        auth_basic "Gerrit";
        auth_basic_user_file /etc/nginx/conf.d/gerrit.htpasswd;
        proxy_set_header Authorization $http_authorization;
        proxy_pass_header  Authorization;

my gerrit config is :

        basePath = git
        canonicalWebUrl = http://gerrit.example.com/
        type = postgresql
        hostname =
        database = reviewdb
        username = gerrit2
        type = LUCENE
        type = HTTP
        smtpServer = mail.vada.ir
        from = ${user} Code Review <git@vada.ir>
        smtpUser = git@vada.ir
        smtpPass = T7SMkUYRqMP

        user = gerrit2
        javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
        listenAddress = *:29418
        listenUrl = proxy-
        directory = cache
        allowRemoteAdmin = true

changing the gerrit authentication is only an option if we can protect it from registration.

Thank you.

  • How does your gerrit.config look like? – StephenKing Dec 7 '15 at 15:16
  • I found thge solution, but I add the config to the post too. – fzerorubigd Dec 8 '15 at 8:03

I found the normal (basic auth) is not working with api in my setup. but using the digets authentication is working without problem.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.