Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some trouble with Nginx and Jenkins (Hudson). Iam trying to use Nginx as Reverse Proxy for the Jenkins instance with HTTP Basic Authentication.

It works so far, but i have no idea how to pass the Header with the AUTH Username?

location / {
  auth_basic "Restricted";
  auth_basic_user_file /usr/share/nginx/.htpasswd;
  sendfile off;

  proxy_redirect     default;
  proxy_set_header   Host             $http_host;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header   X-Forwared-User  $http_authorization; 
  proxy_max_temp_file_size 0;

  #this is the maximum upload size
  client_max_body_size       10m;
  client_body_buffer_size    128k;

  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;             
  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;


share|improve this question
Note you probably want an extra 'd' in "X-Forwared-User". – Paul Jan 29 '15 at 16:44
up vote 2 down vote accepted

Try adding this directives to your location block

proxy_set_header Authorization $http_authorization;
proxy_pass_header  Authorization;
share|improve this answer
This header is passing: Username: Basic YXJuZTpraWxsZXI, not the correct name from http auth (; – opHASnoNAME May 29 '13 at 17:32
This must be base64 encoded string try to decoding it – Andrei Mikhaltsov May 31 '13 at 13:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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