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 apache as a backend and nginx as a frontend. Some content is password-protected by Apache (HTTP Auth).

When I access it directly - everything works fine, bur when I try it through nginx - seems like nginx doesn't forward or cache the responses from Apache. So inside nginx log I see: - - [17/May/2012:22:13:42 +0200]  GET / HTTP/1.1 | upstream_address x.x.x.x:80 | upstream_status 401 | upstream_response_time 0.026 | msec 1337285622.757 | request_time 0.026 - zentavr [17/May/2012:22:13:44 +0200]  GET / HTTP/1.1 | upstream_address - | upstream_status - | upstream_response_time - | msec 1337285624.151 | request_time 0.000

On Apache's side:

y.y.y.y - - [17/May/2012:22:13:42 +0200] "GET / HTTP/1.0" 401 652 "-" "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0" ""

What could be the issue?

share|improve this question
Do you want the client to provide the credentials and have nginx pass them through to Apache, or do you want nginx to provide the credentials to Apache and not require authentication from the client? – mgorven May 17 '12 at 20:50
What error code does the client get? What's the nginx config look like? – Shane Madden May 17 '12 at 21:14
mgorven - the credentials file is on Apache website. So the chain is: Client (enters password) - nginx - Apache with htpasswd database – Andrey Zentavr May 23 '12 at 19:57
Try adding to nginx server configuration: proxy_set_header Authorization $http_authorization; – Andrei Mikhaltsov Aug 24 '12 at 16:42

Your Answer


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

Browse other questions tagged or ask your own question.