Forum Discussion
iRule assistance based on URI and source address
Hey all!
I have an application that currently allows for all users to connect to a java and non java version based on the URI that you browse to. I would like to allow only a specific range of IP addresses to be able to reach the java version, and if you are not coming from that specific range, then I want the users to be forwarded to the non java version.
I tried writing an iRule, but I think I am getting caught up with the redirect to the nonjava version. Any assistance would help.
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/java/version") && ([class match [IP::client_addr] equals JAVA-VERSION-NETS]) } {
pool My-Web-Pool
} else { HTTP::redirect https://application.com/nonjava/version }
}
Assistance would be appreciated.
thanks you ,
RK
Following iRule code should remove the redirect loop to the nonjava version.
when HTTP_REQUEST { if { ([HTTP::uri] contains "/java/version") && ([class match [IP::client_addr] equals JAVA-VERSION-NETS]) } { pool My-Web-Pool } else { if { [HTTP::uri] contains "/java/version" } { HTTP::redirect https://application.com/nonjava/version } pool My-Web-Pool } }
Hope below irule will solve your issue
when HTTP_REQUEST { if { [class match [IP::client_addr] equals JAVA-VERSION-NETS] } { HTTP::redirect "https://application.com/java/version" } else { HTTP::redirect "https://application.com/nonjava/version" } }
- ryank5589Nimbostratus
Samir,
Thanks for the response! I don't understand how the irule you provided distinguishes between the java and nonjava version for the initial traffic. For example, both the java and non java versions are hosted on the same pool members within the same pool, but the only difference is the uri. Any idea how to write an irule for that?
Corrected the iRule.
- NAGCirrostratus
Following iRule code should remove the redirect loop to the nonjava version.
when HTTP_REQUEST { if { ([HTTP::uri] contains "/java/version") && ([class match [IP::client_addr] equals JAVA-VERSION-NETS]) } { pool My-Web-Pool } else { if { [HTTP::uri] contains "/java/version" } { HTTP::redirect https://application.com/nonjava/version } pool My-Web-Pool } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com