Forum Discussion

msaud's avatar
msaud
Icon for Cirrus rankCirrus
Apr 22, 2024

F5 iRule to replace host to path

Hi Team,

Can someone please help me to create iRule to  achieve below requirement.

 

I have created one VS " vs_mule-dev-azure-lb.ucsf.edu_443 and want to route the traffic as below


https://mule-dev-azure-lb.ucsf.edu/dev-versa-chatapi-functions/api/...... --->  https://dev-versa-chatapi-functions.azurewebsites.net/api/....

 

https://mule-dev-azure-lb.ucsf.edu/dev-versa-streaming-functions/api/... ---> https://dev-versa-streaming-functions.azurewebsites.net/api/.

 

 

  • Hi msaud,

    Can you test the iRule?

    when HTTP_REQUEST {
        if { [HTTP::host] eq "mule-dev-azure-lb.ucsf.edu" && [getfield [HTTP::path] "/" 3] eq "api" } {
            HTTP::redirect "https://[getfield [HTTP::path] "/" 2].azurewebsites.net[getfield [HTTP::uri] [getfield [HTTP::path] "/" 2] 2]"
            return
        } 
    }

     

      • spalande's avatar
        spalande
        Icon for Nacreous rankNacreous

        Do you need rewrite on the serverside session or redirect on the clientside (visible in the browser)?. iRule will change depending on the exact requirement.