Forum Discussion

jdhaase01_18884's avatar
jdhaase01_18884
Icon for Nimbostratus rankNimbostratus
Oct 04, 2016

iRule to redirect URL using 8443 to non standard port and pool based on path

We need an iRule using a single VIP that will look at the path and change the port number and use a unique Pool. Here is the logic of how we'd like it to work. I am new to writing iRules and am very green with the F5, so any help would be great.

 

VIP: URL https://myapplication.mycompany.com:8443/XXXX

 

IF XXXX = SB13 then change URL to https://myapplication.mycompany.com:8013/SB13 and use POOL_SB13

 

else IF XXXX = SB14 then change URL to https://myapplication.mycompany.com:8014/SB14 and use POOL_SB14

 

else IF XXXX = SB15 then change URL to https://myapplication.mycompany.com:8015/SB15 and use POOL_SB15

 

else IF XXXX = SB16 then change URL to https://myapplication.mycompany.com:8016/SB16 and use POOL_SB16

 

else IF XXXX = SB17 then change URL to https://myapplication.mycompany.com:8017/SB17 and use POOL_SB17

 

else IF XXXX = SB18 then change URL to https://myapplication.mycompany.com:8018/SB18 and use POOL_SB18

 

else IF XXXX = SB19 then change URL to https://myapplication.mycompany.com:8019/SB19 and use POOL_SB19

 

else IF XXXX = SB20 then change URL to https://myapplication.mycompany.com:8020/SB20 and use POOL_SB20

 

else IF XXXX = SB21 then change URL to https://myapplication.mycompany.com:8021/SB21 and use POOL_SB21

 

else IF XXXX = SB22 then change URL to https://myapplication.mycompany.com:8022/SB22 and use POOL_SB22

 

else IF XXXX = SB23 then change URL to https://myapplication.mycompany.com:8023/SB23 and use POOL_SB23

 

3 Replies

  • Out of curiousity, why do you have to/want to change the URL? You could just use POOL_SB23, for example, and have the pool members listen on the different port without altering what the client sees.

     

  • What ekaleido said or a complicated iRule that is like the below. I'm a script kiddie .. ha and don't have access to a box right now or I'd make sure the syntax is correct. I'm sure someone else will chime in and fix my mess haha.

        when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
        "myapplication.mycompany.com" {
        }
        }
      }   
        "*:8013/SB13" { pool "POOL_SB13" }
        "*:8014/SB14" { pool "POOL_SB14" }
        "*:8015/SB15" { pool "POOL_SB15" }
        "*:8016/SB16" { pool "POOL_SB16" }
        "*:8017/SB17" { pool "POOL_SB17" }
        "*:8018/SB18" { pool "POOL_SB18" }
        "*:8019/SB19" { pool "POOL_SB19" }
        "*:8020/SB20" { pool "POOL_SB20" }
        "*:8021/SB21" { pool "POOL_SB21" }
        "*:8022/SB22" { pool "POOL_SB22" }
        "*:8023/SB23" { pool "POOL_SB23" }
        default { pool "POOL_SB13" }