Forum Discussion
mart_58302
Nimbostratus
Sep 23, 2008Destination based redirect irule, a'la cache.pac implementing?
Hello.
We are using F5 for proxy servers gateway, and everything works fine, but due routings in proxy's if the clients destination is local network, the proxy's can't connect to local network, so in web browsers are using cache.pac where is defined, that if destination is local network, traffic goes directly, not via F5. Example:
function FindProxyForURL(url, host) {
if(shExpMatch(host, "*[^0123456789.]*") == false)
if( isInNet(host, "127.0.0.0", "255.0.0.0")
|| isInNet(host, "172.17.0.0", "255.255.0.0")
|| isInNet(host, "172.18.0.0", "255.255.0.0")
)
return "DIRECT";
else
return "PROXY proxygateway.internal:8080; DIRECT";
)
But clients who can't read/use the cache.pac can't connect local network at all, so is it possible on the F5 with irule do same thing as with cache.pac, that if destination is local network F5 redirects all this traffic to the network directly and without any NAT/SNAT?
- hoolio
Cirrostratus
Hi Mart,when HTTP_REQUEST { Check if host header value only contains numerals or colons ":" The format is {%[CHARS]}, where CHARS can be a character ranges or single characters. The literal hyphern character '-' needs to be listed first or last in the character set if {[scan [HTTP::host] {%[0-9:]}] eq [HTTP::host]}{ Split the host header value on the : if it exists and check if it's part of the stock private_net datagroup if {[matchclass [getfield [HTTP::host] ":" 1] eq $::private_net]}{ Use the direct pool pool direct_pool Stop processing this event in this rule return } } If we reached here, use the proxy pool pool proxy_pool }
- hoolio
Cirrostratus
The forum is munging the scan characters. Replace: - mart_58302
Nimbostratus
- hoolio
Cirrostratus
If you don't have a pool defined to handle the non-proxy requests, you could forward them according to the routing table to their destination. Try replacing 'pool direct_pool' with 'forward'. - mart_58302
Nimbostratus
- hoolio
Cirrostratus
Can you add an HTTP profile to the VIP and test with the example in my first post above? The HTTP profile is required to allow LTM to parse the request as HTTP.when CLIENT_ACCEPTED { if { [matchclass [IP::local_addr] equals $::private_net] } { forward } else { pool live-proxy-pool } }
- mart_58302
Nimbostratus
- hoolio
Cirrostratus
If you define a VIP on 0.0.0.0/0.0.0.0.0 on port 80, this more specific VIP would match all port 80 traffic and you could add an HTTP VIP. But if you want to filter based on the destination address of the connection attempt, the second rule would be more efficient and not require an HTTP profile. - mart_58302
Nimbostratus
- hoolio
Cirrostratus
If the destination IP address on the client request is what you're trying to evaluate, can you try this rule on the 0.0.0.0:80 VIP with no HTTP profile?when CLIENT_ACCEPTED { if { [matchclass [IP::local_addr] equals $::private_net] } { log local0. "[IP::client_addr]:[TCP::client_port]: Request to [IP::local_addr]:[TCP::local_port] matched local addresses" forward } else { log local0. "[IP::client_addr]:[TCP::client_port]: Request to [IP::local_addr]:[TCP::local_port] didn't match local addresses" pool live-proxy-pool } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects