How can I setup an nginx proxy_pass directive that will also include HTTP Basic authentication information sent to the proxy host?
This is an example of the URL I need to proxy to:
http://username:[email protected]/export?uuid=1234567890
The end goal is to allow 1 server present files from another server (the one we're proxying to) without exposing the URI of the proxy server. I have this working 90% correct now from following the Nginx config found here:
http://kovyrin.net/2010/07/24/nginx-fu-x-accel-redirect-remote/
I just need to add in the HTTP Basic authentication to send to the proxy server
I did a writeup on this a while ago. See the details here:
http://shairosenfeld.blogspot.com/2011/03/authorization-header-in-nginx-for.html
For example:
"a2luZzppc25ha2Vk" is "king:isnaked" base64 encoded, so that would work for
http://king:[email protected]
Feel free to check out blog post for more details.
I got this working with alvosu's answer but I had to enter the word "Basic" inside the quotation of the base64 string so it looked like this:
Set
where
USER_AND_PASS = base64(user:pass)
.Remove the authorization header that gets passed forwarded by nginx with
proxy_set_header Authorization "";
.I configured nginx to do basic auth but the
Authorization
header was getting passed along in theproxy_pass
directive and the receiving end couldn't handle the token.(Specific to my case, this error was returned
Reason: No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
)