Forum Discussion
George_Dimitria
Nimbostratus
Dec 15, 2005HTTP to proxy format in order to force the use of a proxy
One way to force the use of a proxy in order to connect to a HTTP server is to use it either as a reverse proxy or a transparent proxy.
Is it possible to use irules on a HTTP virtual server ...
George_Dimitria
Nimbostratus
Dec 20, 2005Changing Code:
http://devcentral.f5.com/Default.aspx?tabid=28&forumid=5&postid=5362&view=topic
when HTTP_REQUEST {
set caddr [IP::client_addr]
set header_host [HTTP::host]
if { $header_host ne "" } {
if { "$caddr" eq "xxx.xxx.xxx.xxx" or "$caddr" eq "yyy.yyy.yyy.yyy" or "$caddr" eq "zzz.zzz.zzz.zzz"} {
request comes from proxy servers
persist source_addr 180
pool POOL_HTTP_SERVERS
} else {
request comes from clients, redirect to proxy servers and rewrite URI
set header_uri [HTTP::uri]
HTTP::uri "http://$header_host$header_uri"
HTTP::header remove "Connection"
HTTP::header insert "Proxy-Connection" "Keep-Alive"
persist source_addr 180
pool POOL_HTTP_PROXIES
}
} else {
HTTP::respond 403 content "HTTP Error 403 - Forbidden"
}
}
when HTTP_RESPONSE {
set caddr [IP::client_addr]
set location [HTTP::header "Location"]
if { "$caddr" eq "xxx.xxx.xxx.xxx" or "$caddr" eq "yyy.yyy.yyy.yyy" or "$caddr" eq "zzz.zzz.zzz.zzz"} {
response from HTTP servers, nothing is needeed
return
} else {
response to clients, Location has to be rewritten.
set loc_start ""
if { $location starts_with "http://" } {
set loc_start "http://"
} elseif { $location starts_with "https://" } {
set loc_start "https://"
}
set loc_start_len [string length $loc_start]
set loc_end [substr $location $loc_start_len]
set loc_to_search [getfield $loc_end "/" 1]
set loc_to_search_len [string length $loc_to_search]
set loc_end [substr $loc_end $loc_to_search_len]
set new_loc $loc_end
HTTP::header replace "Location" $new_loc
return
}
}
Where
xxx.xxx.xxx.xxx
yyy.yyy.yyy.yyy
zzz.zzz.zzz.zzz
are the IP's of the proxy servers, to which the requests are redirected.
Any comments are welcome......
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
