Question

I have two applications which I cannot change:

A: provides a URL protected by HTTP basic auth. B: needs to access this URL but does not support basic auth. Credentials are available.

How can I make my two applications work together?

I thought a local proxy might be great which injects the authentication. E.g. using socat:

socat TCP4-LISTEN:81,reuseaddr,fork TCP:UrlToA:80,<inject-basic-auth>=user:pass

However, socat does not provide an option like < inject-basic-auth >. Anybody knows any tool that might help? Any other way out?

Was it helpful?

Solution

You must set up a HTTP reverse proxy server that does the authentication for you. No need to hack any software.

Your reverse proxy listens on some socket (e.g. proxy:8080) and forwards requests to your actual application A, inserting the headers.

client_B ----> http://proxy:8080 -----> http://server_A:80

Nginx is lightweight, high performance and easy to set up. And it's easy to find docs online for what you want. See for example http://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy

OTHER TIPS

This problem seems to be very specific. So you probably won't find a ready-to-use tool.

If you want to do it yourself, your best approach is probably to extend socat:

http://www.dest-unreach.org/socat/download/socat-1.7.2.2.tar.gz

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top