Forum Discussion
Jim_Betts_47293
Nimbostratus
Mar 25, 2008URL rewrite frustration
Howdy All:
After spending at least 4 hours searching DevCentral and dozens of attempts at trying to code the rules I need some help.
I have a web server (actually a Tumbleweed Secure Messenger) in my internal network (Inside FQDN=securemail.corp.com) that is accessed HTTP via port 8080. All access to this server is via URI "/securemail". I want users on the outside to access this system using HTTPS with our existing site certificate.
I have a large, elaborate iRule that I use to direct people to various pools depending on host names and URI that is working pretty well, what I want to do is to add some URI rewriting so that I can translate the inbound hostname to the inside domain hostname. I'm truncating SSL before I forward the requests but need to ensure that he responses are in SSL. Here is what I have so far:
when HTTP_RESPONSE {
if { $Target_URI starts_with "/messenger" } {
set host "www.mycomp.com"
HTTP::header replace Host "www.mycomp.com"
set location [HTTP::header value Location]
regsub {securemail\.corp\.com} $location "www.mycomp.com" newLocation
HTTP::header replace Location "$newLocation"
}
}
when HTTP_REQUEST {
if { $Target_URI starts_with "/messenger" } {
set host "securemail.corp.com:8080"
HTTP::header replace Host "securemail.corp.com"
set location [HTTP::header value Location]
pool Tumbleweed-SM
}
}
In summary here is what needs to happen:
Inbound request-> https://www.mycomp.com/messenger/xyz
Request forwarded-> http://securemail.corp.com:8080/messenger/xyz
Outbound response-> https://www.mycomp.com/messenger/xyz (with URI generated by server)
Response I'm getting-> http://securemail.mycomp.com/messenger/xyz
Any suggestions would be appreciated.
- Juerg_Wiesmann
Nimbostratus
Hi there,when HTTP_REQUEST { set my_host [string tolower [HTTP::host]] if {[HTTP::host] starts_with "leon.demo.com"} { set destination_host hsrvepp1.demo.com set source_host http://leon.demo.com HTTP::header replace "Host" $destination_host} log local0. [HTTP::header Host] } when HTTP_RESPONSE { set server_location [string tolower [HTTP::header Location]] if {$server_location starts_with "http://hsrvepp1.demo.com"} { HTTP::header replace "Location" $source_host} log local0. [HTTP::header Location] }
- Jim_Betts_47293
Nimbostratus
Dear Weismann: - hoolio
Cirrostratus
Hi Jim,when HTTP_RESPONSE { if { [HTTP::status] == 302 and $Target_URI starts_with "/messenger"} { HTTP::header replace Location [string map {http:// https://} [HTTP::header value Location]] } }
- Jim_Betts_47293
Nimbostratus
Thank you sir, your suggestion has been implemented.
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