title: Protect Jenkins with nginx http auth except callback url
body: <p>I installed jenkins on my server and I want to protected it with nginx http auth so that requests to:</p>
  
  <pre><code>http://my_domain.com:8080
  http://ci.my_domain.com
  </code></pre>
  
  <p>will be protected except one location:</p>
  
  <pre><code>http://ci.my_domain.com/job/my_job/build
  </code></pre>
  
  <p>needed to trigger build. I am kinda new to nginx so I stuck with nginx config for that.</p>
  
  <pre><code>upstream jenkins {
    server  127.0.0.1:8080;
  }
  
  server {
    listen x.x.x.x:8080;
    server_name *.*;
  
    location '/' {
      proxy_pass http://jenkins;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
  
      auth_basic "Restricted";
      auth_basic_user_file /path/.htpasswd;    
    }
  }
  </code></pre>
  
  <p>I tried smth like above config but when I visit <code>http://my_domain.com:8080</code> there is no http auth.</p>