Forum Discussion

Deepak_Nair's avatar
Feb 17, 2021

IRULE to MATCH any URI after the HTTP HOST Header

Hi Experts ,

 

I am working on one request where CLIENT makes a request to VIP using https://myjobrocks.com/xyz .This URL should be re-builded to another URI https://myjobrocks.com/xyz or https://myjobrocks.com/xyz/home etc and send to node in the backend server using its machine name .

 

Client to VIP ----> https://myjobrocks.com/xyz

 

VIP to Backend ----> https://<machine-name>:443/xyz

 

Client should NOT see the VIP to backend communication .

 

ALSO , the /xyz PATH contains /xyz/home/groups/siginin etc pages in it

 

I wrote an IRULE but it works only a part of xyz/home URI , not for other PATH when I click while I reach /xyz/home

 

When I click something in the Home page , its returns 404 error .

 

 

when HTTP_REQUEST { 

  if {([string tolower [HTTP::host]] equals "myjobrocks.com") &&  [HTTP::uri] starts_with "/xyz" } 

   

{

HTTP::uri "/xyz[HTTP::uri]

node 1.1.1.1 443

}

 

I am NOT sure how to append the REST of URI request made by the Client .

 

 

 

 

4 Replies

  • OK this works now . Just created a VIP with Port 80 and attached the irule below

     

    when HTTP_REQUEST { 

      if {([string tolower [HTTP::host]] equals "myjobrocks.com") &&  [HTTP::uri] starts_with "/xyz" } 

       

    {

    HTTP::uri "/xyz[HTTP::uri]

    node 1.1.1.1 80

    }

     

     

    Thanks Every one .

     

  • Hello,

     

    When you are hitting URI /xyz/home or xyz/something, do you see if whole URI is preserved in the browser?

  • Hi Mayur ,

     

    When i browse to https://myjobrocks.com/xyz it HITS the F5 VIP and land on https://myjobrocks.com/xyz/home perfectly using below irule :

     

    when HTTP_REQUEST { 

      if {([string tolower [HTTP::host]] equals "myjobrocks.com") &&  [HTTP::uri] starts_with "/xyz" } 

       

    {

    node 1.1.1.1 443

    }

     

    Inside Home i have different PATH and when i click on that i can see the PATH are preserved in the browser but when that PATH is appended , the request change from https to http . i am NOT sure why is this happening . Also when i try to open .html page within Home , its stays as https BUT gets a error as below

     

    Invalid redirect_uri

     

    Error: 400

     

    When i USe this irule :

     

    when HTTP_REQUEST { 

      if {([string tolower [HTTP::host]] equals "myjobrocks.com") &&  [HTTP::uri] starts_with "/xyz" } 

       

    {

    HTTP::uri "/xyz[HTTP::uri]

    node 1.1.1.1 443

    }

     

    Nothing works and gets server error .

     

     

  • OK i think i found the problem . The other URI path within /XYZ is hosted on http instead of https . Looks like i need to create a VIP with port 80 to service this paths .

     

    testing this now