Forum Discussion

Fenton_376179's avatar
Fenton_376179
Icon for Nimbostratus rankNimbostratus
Nov 12, 2018

Redirect device based on Source IP

HI. I have an issue where we have two different VIPs/URLs servicing similar information to two different part of the company. This is normally ok, until somebody from one part copies their URL and sends out to both part of the organisation in an email, then users who should go to website B get directed to Website A and it all falls apart. I am looking to inspect the IP address and if they have been directed to the wrong site redirect then to the correct site.

 

I have created the i-rule below but it seems to be ignored. And help would be great

 

when CLIENT_ACCEPTED { if { [IP::remote_addr] equals "10.1.14.131 mask 255.255.255.255"} { http:: redirect to "; } elseif {[IP::remote_addr] equals "10.0.0.0 mask 255.0.0.0"} { pool "iapp_sharepoint_pool"} }

 

1 Reply

  • Something like below would do, 1 common Irule that can be applied in both your VIP's. Create 2 datagroups with type IP and but the A users subnet in A_Users_Ips and B users subnet in B_Users_Ips.

    Req:

    • A users alone to access A website
    • B users alone to access B website
    • A users if access B website, redirect to A website.
    • B users if access A website, redirect to B website.

    Irule:

    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "www.a.com" and (![class match [IP::remote_addr] equals A_Users_Ips]) } { 
    HTTP::redirect "https://www.b.com[HTTP:uri]"
    log local0. "User [IP::remote_addr] is NOT from A subnet and hence redirected to B website"
    } elseif { [string tolower [HTTP::host]] equals "www.b.com" and (![class match [IP::remote_addr] equals B_Users_Ips]) } { 
    HTTP::redirect "https://www.a.com[HTTP:uri]"
    log local0. "User [IP::remote_addr] is NOT from B subnet and hence redirected to A website"
    }
    }