Forum Discussion
v12 URL/URI Rewrite
I am in need of rewriting the url https://site1.domain.com to https://site2.sub.domain.com/widget in v12.x code. Best to use an iRule or a rewrite profile (for a non apm portal configuration)? What would the irule look like for this scenario?
I've used ProxyPass for this in the past but was curious about a basic irule that would do the same translation
Any insight is appreciated
5 Replies
- Vijay_E
Cirrus
Untested:
when HTTP_REQUEST { if { ([HTTP::host] equals "site1.domain.com") } { HTTP::host [string map {site1.domain.com site2.subdomain.com} [HTTP:host]] } } when HTTP_RESPONSE { if { [HTTP::header values Location] contains "site2.subdomain.com" } { HTTP::header replace Location [string map {site2.subdomain.com site1.domain.com} [HTTP::header value Location]] } } Fortunately in v12, an iRule is no longer needed for this type of translation. The rewrite profile is what you would use, especially if you used the proxy-pass iRule in the past.
Simply rewriting the Host header in the request and Location headers in the response will not address URLs that exist in HTML content.
Simply create a uri-translation rewrite profile and add a URL rule:
Client URL: https://site1.domain.com/ Server URL: https://site2.sub.domain.com/widget/Notice the URLs end in a
./- JQUINONES82NB
Nimbostratus
Instead of sending the rewrite to a uri can we send it to a f5 pool?
- dsjustin_273687
Nimbostratus
I tried the rewrite profile, but I'm still seeing the hosts field come up as site1.domain.com as opposed to site2.sub.domain.com in my packet captures. For me, I don't need the uri replaced, I want that to go through.
My rewrite profile is set for client url: https://site1.domain.com/ Server url: https://site2.sub.domain.com/
Any idea why the host headers wouldn't be re-written?
- Vijay_E
Cirrus
From the client device, perform a curl to site1.domain.com and from the F5, perform a curl to site2.domain.com just to see the response from server. This will help you to isolate the problem and troubleshoot further.
Recent Discussions
Related Content
* 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