kgaigl
1
Hello,
need some help:
I’ve got the need to rewrite URI from domain.com/internal to domain.com/home but only when traffic comes from outside, not from inside (=private net)
the rewrite of the URI I could achieve with a LTM-Policy but not in combination with the second condition. Am I right?
Could someone help me with a IRule?
would be great, thanks
Hi kgaigl,
when HTTP_REQUEST {
if { ([HTTP::host] equals "domain.com") and ([string tolower [HTTP::uri]] starts_with "/internal") } {
switch -glob [IP::client_addr] {
"10.*" -
"192.168.*" -
"172.16.*" -
"172.17.*" -
"172.18.*" -
"172.19.*" -
"172.20.*" -
"172.21.*" -
"172.22.*" -
"172.23.*" -
"172.24.*" -
"172.25.*" -
"172.26.*" -
"172.27.*" -
"172.28.*" -
"172.29.*" -
"172.30.*" -
"172.31.*" {
# log local0. "Host: [HTTP::host] Uri: [HTTP::uri] ClientIP: [IP::client_addr]"
}
default {
HTTP::redirect "https://domain.com/home"
# or
# HTTP::uri "/home"
}
}
}
}
kgaigl
3
Hi eaa,
thanks a lot, but I can test it not before next week.
one question: in another IRule there is a string:
if {!([class match [IP::client_addr] equals private_net])}
could I use the expression “private_net” to shorten the rule?
Yes, you can use instead of switch statement.
when HTTP_REQUEST {
if { ([HTTP::host] equals "domain.com") and ([string tolower [HTTP::uri]] starts_with "/internal") } {
if { not ([class match [IP::client_addr] equals private_net]) } {
HTTP::redirect "https://domain.com/home"
# or
# HTTP::uri "/home"
}
}
}