Forum Discussion

galou_31358's avatar
galou_31358
Icon for Nimbostratus rankNimbostratus
Jun 14, 2011

transform juniper redirector and cluster to VS using irule

Hi all

 

I'm new in iRule developping, i would like just transforming this redirector and cluster Juniper DX to a virtual server.

 

 

Do i need to create to 2 VS, one VS for redirect using an irule and a second standard VS with snat automap?

 

 

In this configuration, the user is redirected from 1.2.3.4:80 to the cluster 1.2.3.4:8080 with a new URI:new_uri/test

 

 

set cluster foo listen vip 1.2.3.4

 

set cluster foo listen netmask 255.255.255.255

 

set cluster foo listen port 8080

 

set cluster foo target host 5.6.7.8:8080

 

set cluster foo target name foo.bar.com

 

 

 

set redirector foo listen netmask 255.255.255.255

 

set redirector foo listen port 80

 

set redirector foo name foo

 

set redirector foo listen vip 1.2.3.4

 

set redirector foo port 8080

 

set redirector foo protocol http

 

set redirector foo host foo.bar.com

 

set redirector vega customurl new_uri/test

 

 

Thanks for your help.

 

5 Replies

  • It would be simpler to create one HTTP VS on port 80 and another on port 443. The pool for the HTTPS VS would contain the server IP:port 1.2.3.4:8080.

    You can use an iRule like this to redirect requests to the HTTP VS to HTTPS:

    
    when HTTP_REQUEST {
       HTTP::redirect "https://foo.bar.com/new_uri/test"
    }
    

    Aaron
  • Hi Aaron

     

    Thanks but the second VS should use port 8080 on http protocol.

     

    So how can i transform the iRule?

     

     

  • You could use this if the second VS is HTTP on port 8080:

    
    when HTTP_REQUEST {
       HTTP::redirect "http://foo.bar.com:8080/new_uri/test"
    }
    

    Aaron
  • Thanks Aaron.

     

    is it the same if i use this iRule:

     

    when HTTP_REQUEST{

     

    virtual foo8080

     

    HTTP:uri "new_uri/test"

     

    }
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    A redirect and the HTTP::uri command are different. If you want to just replace the URI for this particular request between the LTM and the back end servers, HTTP::uri will do just that. However, if you want to issue a redirect to the client so they make a new connection to a different specified host/URI and permanently move the transaction over to that location, then HTTP::redirect is your ticket.

     

     

    Colin