I am trying to create a transparent reverse proxy using org.restlet.routing.Redirector
.
For the sake of simplicity let's say all I want to do is to redirect all HTTP requests pointing at
http://localhost:80
to be dispatched to another unrelated HTTP server:
http://localhost:8080
I've wrote a simple reverse proxy using Redirector (MODE_SERVER_OUTBOUND mode) and it actually works as expected in the sense that it dispatches requests properly and also handles redirects.
But now let's say that resources at http://localhost:8080
are protected with Digest authentication mechanism.
Now the problem is that headers in requests and responses when handled by Redirector are removed (from docs WRT MODE_SERVER_OUTBOUND
):
Note that in this mode, the headers of HTTP requests, stored in the request's attributes, are removed before dispatching. Also, when a HTTP response comes back the headers are also removed.
which makes Digest authentication mechanism unusable.
I guess that reverse proxy should return responses as if it was itself the origin.
Is there any way to leave headers intact so that end server (http://localhost:8080
) and clients could communicate as there is no proxy in between?
Thanks to Arjohn (see related discussion in Restlet mailing list) the solution was found:
We've updated from restlet 2.1.4 to 2.2.0 now and to our surprise this fixed the Redirector problems. In fact, Redirector works perfectly out-of-the-box, including the digest authentication. No subclassing required. So probably this was a bug in 2.1.4 that has been fixed somewhere in the 2.2 development.