Issue with NGINX as reverse proxy with basic auth in front of Apache with basic auth

ssaravalli nginx-forum at
Wed Aug 31 10:07:27 UTC 2011

Hello to everybody, my name is Simone Saravalli and I'm new to NGINX

This is my problem: I set up NGINX as a reverse proxy to a backend
server with Apache. On NGINX side I configured basic authentication for
/ location:

      location / {
          auth_basic             "Restricted";
          auth_basic_user_file   /etc/nginx/htpasswd;
          proxy_pass   ;
          proxy_redirect         off;
          proxy_set_header       Authorization "";
          proxy_set_header       Host $host;
          proxy_set_header       X-Real-IP $remote_addr;
          proxy_set_header       X-Forwarded-For
          proxy_set_header       X-Forwarded-Ssl on;

In this way, when a user goes to (say the ip of the
NGINX reverse proxy), he's prompted for username/password and then
redirected to as expected.

The problem: if on Apache I set another step of authentication (basic
auth, LDAP) something goes wrong. From NGINX's logs I see when I sent
username/password for Apache. From Apache's logs I cannot see anything.
Obviously I got an error because NGINX doesn't know these
username/password because they are for Apache.

How can I solve this problem?

Thanks in advance for any reply. Regards.

Posted at Nginx Forum:,214550,214550#msg-214550

More information about the nginx mailing list