cancel
Showing results for 
Search instead for 
Did you mean: 

iRule - Combine HTTP::redirect and Basic Auth in HTTP header

Gerald_Meese
Altostratus
Altostratus

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

 

1 REPLY 1

Stanislas_Piro2
Cumulonimbus
Cumulonimbus

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" } }