Forum Discussion
Ross_Fitheridge
Nimbostratus
Nov 09, 2007rewrite absolute URI to relative URI
we are having difficulty with a Virtual Server, that is configured for SSL server off-load. Most clients work, however we have one (the most important (of course) that comes through a Proxy). The Squid Proxy makes a call using an absolute URI with the protocol HTTPS: (https://www.company.com:8443/service), however the server only understands HTTP. The LTM is not translating the URI from https to http.
If I could just change the URI from https to http it would do the job.
I have attempted to rewrite the URI from an absolute to a relative URI, but this is not working. When I log the URI before and after it is still the same. The iRule I am trying follows:
Rule to modify absolute URI to relative URI
when HTTP_REQUEST {
set relativeUri "[URI::path [HTTP::uri]][URI::basename [HTTP::uri]][HTTP::query]"
HTTP::uri $relativeUri
}
I thought this was going to be simple, and I hope you are going to show me it is :-)
3 Replies
- hoolio
Cirrostratus
The value for HTTP::uri is cached, so you won't see the update. If you log the value for $relativeUri, is it what you expect?
Also, I would expect that the web server(s) in the pool would be able to parse an absolute URI, so you could just replace https:// with http:// using string map, instead of using all of the URI:: and HTTP:: commands. Here's an example to log the pre- and post-change URIs:Rule to modify absolute URI to relative URI when HTTP_REQUEST { set relativeUri "[URI::path [HTTP::uri]][URI::basename [HTTP::uri]][HTTP::query]" log local0. "Original URI: [HTTP::uri], modified URI: $relativeUri" HTTP::uri $relativeUri }
And here's an example that just replaces the https: with http:, keeping the absolute URI:Rule to modify absolute URI from HTTPS to HTTP when HTTP_REQUEST { Use string map to replace "https:" with "http:" in the URI set modifiedUri [string map {https: http:} [HTTP::uri]] log local0. "Original URI: [HTTP::uri], modified URI: $modifiedUri" HTTP::uri $modifiedUri }
Once you have it tested, you can remove the logging and variable:Rule to modify absolute URI from HTTPS to HTTP when HTTP_REQUEST { Use string map to replace "https:" with "http:" in the URI HTTP::uri [string map {https: http:} [HTTP::uri]] }
Aaron - Deb_Allen_18Historic F5 AccountHTTP::uri is supposed to return a string containing the location + query string.
If you are seeing that it isn't, what version are you on? - Ross_Fitheridge
Nimbostratus
Hi Deb,
the Version is 9.1.2
The URI does not return the query string. it seems in the code I original wrote I had the query string duplicated!
This is the code I am using to prove this is .....
when HTTP_REQUEST {
Use string map to replace "https:" with "http:" in the URI
set modifiedUri [string map {https: http:} [HTTP::uri]]
set relativeUri "[URI::path [HTTP::uri]][URI::basename [HTTP::uri]]"
log local0. "Original URI: [HTTP::uri], modified URI: $modifiedUri , Relative Uri: $relativeUri , IP: [IP::client_addr], HTTP Query: [HTTP::query]"
HTTP::uri $modifiedUri
}
And a log entry ....
Nov 12 08:44:56 tmm tmm[738]: Rule uri_https_to_http : Original URI: https://partneruat.acmebusiness.com:8443/OTAService/, modified URI: http://partneruat.acmebusiness.com:8443/OTAService/ , Relative Uri: /OTAService/ , IP: 129.35.201.38, HTTP Query: xml
RossF
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
