Forum Discussion
mart_58302
Nimbostratus
Aug 15, 2008Serving wpad.dat with F5?
Hello.
Maybe wrong area, but I'm trying to find out, is it possible to use F5 himself as web server, to serve text based file like wpad.dat or cache.pac for clients?
How to do it?
- James_Quinby_46Historic F5 AccountMart -
- mart_58302
Nimbostratus
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"; )
- hoolio
Cirrostratus
Hi Mart,when HTTP_REQUEST { Check if request is for wpad.internal/wpad.dat if {[string tolower "[HTTP::host][HTTP::uri]"] eq "wpad.internal/wpad.dat"}{ HTTP::respond 200 content {\ 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"; } } } }
- mart_58302
Nimbostratus
when HTTP_REQUEST { Check if request is for wpad.internal/wpad.dat if {[string tolower "[HTTP::host][HTTP::uri]"] eq "wpad.internal/wpad.dat"}{ HTTP::respond 200 content {\ 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"; } } } }
- hoolio
Cirrostratus
If you attach that rule to a VIP with no default pool, the rule will answer requests made to the VIP with a host header value of wpad.internal with a URI of wpad.dat. If a request is made with a different host header value or a different URI, the request will be dropped because the rule will do nothing and there is no default pool to handle the request.when HTTP_REQUEST { Check if requested Host header is wpad.internal if {[string tolower [HTTP::host]] eq "wpad.internal"}{ Check the requested URI switch -glob [HTTP::uri] { "/wpad.dat*" - "*cache1.pac" - "*cache2.pac" { HTTP::respond 200 content {\ 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";} } default { Take some default action? } } } }
when HTTP_REQUEST { Send the wpad.dat content HTTP::respond 200 content {\ 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";} } }
- mart_58302
Nimbostratus
when HTTP_REQUEST { Send the wpad.dat content HTTP::respond 200 content {\ 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 proxy.polsise:8080; DIRECT"; \ else \ if( isPlainHostName(host) \ || shExpMatch(host, "*.internal") \ || shExpMatch(host, "*.testing") \ ) \ return "DIRECT"; \ else \ return "PROXY proxygateway.internal:8080; DIRECT";} } }
- hoolio
Cirrostratus
Sorry... the outside braces mean you don't need to escape the new lines.when HTTP_REQUEST { HTTP::respond 200 content { 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"; } } }
- mart_58302
Nimbostratus
- mart_58302
Nimbostratus
when HTTP_REQUEST { Check if requested Host header is wpad.internal if {[string tolower [HTTP::host]] eq "wpad.internal"}{ Check the requested URI switch -glob [HTTP::uri] { "/wpad.dat*" - "*cache1.pac" - "*cache2.pac" { HTTP::respond 200 content { 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";} } default { Take some default action? } } } }
- hoolio
Cirrostratus
Hi Mart,
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