For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Draven_186334's avatar
Draven_186334
Icon for Altocumulus rankAltocumulus
Feb 10, 2015
Solved

Rewrite Public Host Name to Internal Host Name

Hello,

 

Trying to modify the public URL to the local URL for IIS backend servers, along with using host header redirection.

 

So trying to -

 

draven.com rewrite to draven.local - then switch HTTP:host pool IIS_Server_Draven_pool and ninja.com rewrite to ninja.local - then switch HTTP:host pool IIS_Server_Ninja_pool

 

What I have so far with the host header redirection -

 

when HTTP_REQUEST { switch [HTTP::host] { ninja.com { pool IIS_Server_Pool_Ninja } draven.com { pool IIS_Server_Pool_draven } default { reject } } }

 

Im having trouble working out how to preform the rewrite then switch the host header to the correct pool. I have made the public URL working going direct to the backend server through the host header redirection.

 

Additional would like to try to have the ".com" being rewrote to ".local" en mass rather then code per site. Thanks in advance.

 

  • Solution Found -

     

    WHEN HTTP_REQUEST { set header [string map {".com" ".local"} [HTTP::header "Host"]] HTTP::header replace host $header switch $header { ninja.local { pool IIS_Server_Pool_Ninja } draven.local { pool IIS_Server_Pool_draven } default { reject } } }

     

    Thanks For your help

     

4 Replies

  • Hi, you need to change only the host header request? Try something like this:

    when HTTP_REQUEST {
        set host [string map {".com" ".local"} [HTTP::host]]
        HTTP::host $host
    
        switch $host { 
            ninja.local { pool IIS_Server_Pool_Ninja } 
            draven.local { pool IIS_Server_Pool_draven } 
            default { reject } 
        }
    }
    
  • When using -

    when HTTP_REQUEST { set host [string map {".com" ".local"} [HTTP::host]] HTTP::host $host

    switch host { 
        ninja.local { pool IIS_Server_Pool_Ninja } 
        draven.local { pool IIS_Server_Pool_draven } 
        default { reject } 
    }
    

    }

    Updating the iRule returns an error - [wrong args] [HTTP::host $host]

    Addtionally when using -

    when HTTP_REQUEST { HTTP::host [string map {".com" ".local"} [HTTP::host]]

    switch HTTP:host { 
        ninja.local { pool IIS_Server_Pool_Ninja } 
        draven.local { pool IIS_Server_Pool_draven } 
        default { reject } 
    }
    

    }

    Updating the iRule - line 2: [wrong args] [HTTP::host [string map {".com" ".local"} [HTTP::host]]]

    Any advice on what im doing wrong?

    • cjunior's avatar
      cjunior
      Icon for Nacreous rankNacreous
      I think you missed here: "switch **host** {" have to be like this: "switch **$host** {". But, taking the hint of Parker, do not use variable, do the following: when HTTP_REQUEST { HTTP::host [string map {".com" ".local"} [HTTP::host]] switch [HTTP::host] { ninja.local { pool IIS_Server_Pool_Ninja } draven.local { pool IIS_Server_Pool_draven } default { reject } } }
  • Solution Found -

     

    WHEN HTTP_REQUEST { set header [string map {".com" ".local"} [HTTP::header "Host"]] HTTP::header replace host $header switch $header { ninja.local { pool IIS_Server_Pool_Ninja } draven.local { pool IIS_Server_Pool_draven } default { reject } } }

     

    Thanks For your help