Apache rewrite with intermediate proxy server (with authentication)

apache-2.2mod-proxymod-rewritePROXY

Using Apache 2.2, I'd like to access an external server (reachable through the Internet) from one of my internal servers. The URLs will be rewritten to change the host so I'll either use mod_rewrite or mod_proxy, not sure yet which one is better for the task.

The problem is that to access the Internet with HTTP, we must use a proxy with authentication.

As I'm probably not very clear, here is a small diagram:

             -----      ---------      -----
clients ---> - A - ---> - proxy - ---> - B -
             -----      ---------      -----

A is the internal server, B is the external server.

I'd like URLs like http://A/fu/bar to be redirected to http://B/fu/bar , knowing there is a proxy requiring authentication in between.

I've tried using ProxyRemote using this syntax:

ProxyRemote * http://proxy.mynetwork.com:8080

It seems to go trough the proxy correctly: when I enter an URL http://A/fu/bar, I get the error "HTTP/1.1 407 proxy authentication required". I just don't know how I can specify the credentials for the proxy.

Best Answer

Looks like a no-go right now with stock Apache, but there's a half-decade-old proposed feature add (with a source patch) outstanding.

If you're feeling enterprising, it should be workable to get this ported to current Apache and recompiled.