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

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


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

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             http://xxx.xxx.xxx.xxx;
          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_add_x_forwarded_for;
          proxy_set_header       X-Forwarded-Ssl on;
      }

In this way, when a user goes to http://192.168.0.10 (say the ip of the
NGINX reverse proxy), he's prompted for username/password and then
redirected to http://xxx.xxx.xxx.xxx 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: http://forum.nginx.org/read.php?2,214550,214550#msg-214550



More information about the nginx mailing list