Apache2 – Reverse Proxy with Authentication on Windows 7

apache-2.2reverse-proxywindows 7

I am trying to setup an Apache2 reverse proxy from my laptop (Windows 7, Apache 2.2.17) to a Nexus server (Windows Server 2003) on our network. This is just a test before setting this up for real on an Internet-visible server that we have. I can get the proxy itself setup and proxying Nexus beautifully. But when I try to apply authentication to the proxy, that's when things go wrong. I want to listen on port 8090.

Here are the relevant bits from my httpd.conf file:


Listen 8090

ProxyRequests Off
ProxyPreserveHost On

<Proxy /nexus>
    Order deny,allow
    Allow from all
</Proxy>

<Location /nexus>
    Order deny,allow
    Allow from all

    ProxyPass http://secret.mydomain.com:8082/nexus
    ProxyPassReverse http://secret.mydomain.com:8082/nexus

    AuthType Basic
    AuthName "Nexus"
    AuthBasicProvider file
    AuthUserFile c:\tmp\users

    Require valid-user
</Location>

If I comment out all the Auth* directives, the proxying to Nexus works a treat using a URL like http://localhost:8090/nexus/content/groups/central/ But once I add those Auth* directives back in, I get a login box, enter valid credentials, and then it prompts again. And again. And again. The one thing I noticed, is that the first time the credentials dialog appears, the realm shows up as "Nexus" (as I have it in httpd.conf). But on all subsequent prompts, it shows as "Sonatype Nexus Repository Manager," which, I assume, is coming from the Nexus server itself, even though it doesn't require authentication.

Also, I know that the password file and user/password are good, because if I setup authentication using them just for a local directory, it works fine.

I've found various blog posts about reverse proxies, and about authentication, but I just can't seem to make them work together. I've tried many things, but this is the problem distilled down to its simplest, I think.

Does anyone see anything blatantly wrong with my config? Or anything subtly wrong with it?

Best Answer

Your user auth is being passed to backend, you could try unsetting the authentication header with

RequestHeader unset Authorization