Forum Discussion

F5Hopper_28651's avatar
F5Hopper_28651
Icon for Nimbostratus rankNimbostratus
Dec 17, 2012

dev servers irule

hey guys,

 

not sure how to do this one, I have

 

dev01.www.etc.com, dev02.www.etc.com, through dev20.www.etc.com

 

I also have

 

dev01.app.etc.com through dev20.app.etc.com.

 

 

I want to make an irule that forwards a URI from www to app.

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] eq "/production/webservice.asmx" } {

 

HTTP::redirect "http://dev16.app.etc.com/webservice.asmx"

 

}

 

}

 

I have this on the dev--.www.etc.com VS, I have one VS for all DEV01-20 and use an irule for node redirect based on what DEV they are calling. but as you see it is only forwarding to dev16.

 

if it hits dev05.www I wanted it to forward to the dev05.app

 

4 Replies

  • OK, I'm no expert and haven't used findstr much or had to use variables with redirect but here's my first attempt. The idea is to check for a request containing www, pull out the server number and redirect to the correct app domain/server;

    
    when HTTP_REQUEST {
     if { [string tolower [HTTP::host]] contains ".www." } {
      set devserverid [findstr [HTTP::host] "dev" 0 "."]
      log local0. "Found $devserverid in HTTP host"
      HTTP::redirect "http://dev" + "$devsererid" + ".app.etc.com[[http:uri]]"
      }
    }
    
  • Nice I tweeked it a bit, but the core was solid.

     

     

    when HTTP_REQUEST {

     

    if { ([string tolower [HTTP::host]] contains ".www." )

     

    and ([string tolower [HTTP::uri]] eq "/webapiproduction/webservice.asmx") } {

     

    set devserverid [findstr [HTTP::host] "dev" 0 "."]

     

    HTTP::redirect "http://$devserverid.app.etc.com/webservice.asmx"

     

    }

     

    }

     

     

    This works for all Dev01-20, listening for www and the /webapiproduction/webservice.asmx then sending them to dev01-20.app.etc.com/webservice.asmx

     

     

    Thanks for all the help

     

    Ryan
  • code -

     

    
    when HTTP_REQUEST {
     if { ([string tolower [HTTP::host]] contains ".www." )
    and ([string tolower [HTTP::uri]] eq "/webapiproduction/webservice.asmx") } {
      set devserverid [findstr [HTTP::host] "dev" 0 "."]
      HTTP::redirect "http://$devserverid.app.etc.com/webservice.asmx"
      }
    }