11-Jan-2018 01:35
Hello,
I'm trying to adapt an iRule that would combine the redirect to a specific URI on the backend server, while sending Basic Authentication in an HTTP header to that backend server :
when HTTP_REQUEST {
set logindata [b64encode "username:password"]
HTTP::redirect "/internalURI"
HTTP::header replace Authorization "Basic $logindata"
}
Both commands work well separately, and I believe I understand where the problem is (the redirect sends a new path to the client while the HTTP header is added into the traffic to the backend) but I can't figure out how to get this to work.
Thanks in advance for your help !
Kind regards,
Gerald
11-Jan-2018 01:53
You can try this code:
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/internalURI"} {
set logindata [b64encode "username:password"]
HTTP::header replace Authorization "Basic $logindata"
} else {
HTTP::redirect "/internalURI"
}
}