Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

Redirect HTTP along with header

Mohammad_1363
Altocumulus
Altocumulus

Hello

I am trying to redirect HTTP request from one service to another URL like below

when HTTP_REQUEST {

   if { [string tolower [HTTP::host]] equals "service-api.xx.com" } {

      HTTP::redirect "https://newservice.api.xx.com/test-cg[HTTP::uri]"

      HTTP::header ????

   }

}

so when client initiate a request the initial call comes to the F5 and F5 will redirect from service-api.xx.com to https://newservice.api.xx.com/test-cg[HTTP::uri] the redirection is happening as expected but looks like when the initial call is coming, comes with a header to send the auth to the the token key, the example of initial call is https://new-api.xx.com/auth/sessions so my question is how can i send the header and its value while i am redirecting the request.

 

 

Thanks

1 REPLY 1

SanjayP
MVP
MVP

You can try below

when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::host]] {
	  "service-api.xx.com"
	   {
	    if { [HTTP::header exists "Auth_header"] } {
        set token [HTTP::header value Auth_header]
		HTTP::respond 301 Location https://newservice.api.xx.com/test-cg[HTTP::uri]" "Auth_header" "$token"
		return
           }
           } default {
          return
      }
    }
 }