Forum Discussion
URL/URI rewrite without changing in Client browser
- 3 years ago
I'd maybe argue that partitions aren't create separate logical BIG-IPs. It's more about building separate administrative domains on a single BIG-IP. Further, partitions can always access the /Common partition. To answer your question though, it depends on the level of isolation, but you should simply be able to point to the VIP in the oter partition,
virtual "/abc-app-dev/np-api-vip" or virtual "/Common/abc-app-dev/np-api-vip"You don't need SNAT to communicate between VIPs on the same BIG-IP.
- 3 years ago
Hi Kevin,
Thanks for your guidance. Here is what I figured out and it is working now. All happened due to your idea so thanks again.
IRule for same routing domain :-
when HTTP_REQUEST {
log local0. "Incoming request: [HTTP::host]:[HTTP::uri]"
if { [set match [class match -value -- "[HTTP::host]:[HTTP::uri]" starts_with datagroup_Name]] ne "" } {
log local0. "Datagroup match: $match"
## Get first URI path in client request
set FIRSTPATH [getfield [HTTP::path] "/" 2]
## Split match into host and path
set matchlist [split $match ":"]
set MATCHHOST [lindex $matchlist 0]
set MATCHPATH [lindex $matchlist 1]
## Replace FIRSTPATH with MATCHPATH (from full HTTP::uri)
set UPDATEDPATH [string map [list "/$FIRSTPATH" "$MATCHPATH"] [HTTP::uri]]
log local0. "Updated host: $MATCHHOST"
log local0. "Updated path: $UPDATEDPATH"
HTTP::host $MATCHHOST
HTTP::uri $UPDATEDPATH
virtual "/path/virtual_server_name"
}
}For different route domain
when HTTP_REQUEST {
log local0. "Incoming request: [HTTP::host]:[HTTP::uri]"
if { [set match [class match -value -- "[HTTP::host]:[HTTP::uri]" starts_with datagroup_name]] ne "" } {
log local0. "Datagroup match: $match"
## Get first URI path in client request
set FIRSTPATH [getfield [HTTP::path] "/" 2]
## Split match into host and path
set matchlist [split $match ":"]
set MATCHHOST [lindex $matchlist 0]
set MATCHPATH [lindex $matchlist 1]
## Replace FIRSTPATH with MATCHPATH (from full HTTP::uri)
set UPDATEDPATH [string map [list "/$FIRSTPATH" "$MATCHPATH"] [HTTP::uri]]
log local0. "Updated host: $MATCHHOST"
log local0. "Updated path: $UPDATEDPATH"
HTTP::host $MATCHHOST
HTTP::uri $UPDATEDPATH
pool pool_name
}
}
Yes. This is the tmsh representation of a data group that I created in the UI.
Hi Kevin,
Thank your response. If the resource path is wild card (path (/xyz or /abc/12 or any instead of /test)) for say after www.blah.com/blah/anything can that be translated to www.test.com/test/(anything)
How this can be matched in data group creation?
Thanks,
Prasenjit
- Kevin_Stewart3 years ago
Employee
Okay, so small modification. This assumes the path to be replaced is the first path in the URI:
when HTTP_REQUEST { if { [set match [class match -value -- "[HTTP::host]:[HTTP::uri]" starts_with url_datagroup]] ne "" } { ## Get first URI path in client request set FIRSTPATH [getfield [HTTP::path] "/" 2] ## Split match into host and path set matchlist [split $match ":"] set MATCHHOST [lindex $matchlist 0] set MATCHPATH [lindex $matchlist 1] ## Replace FIRSTPATH with MATCHPATH (from full HTTP::uri) set UPDATEDPATH [string map [list "/$FIRSTPATH" "$MATCHPATH"] [HTTP::uri]] log local0. $UPDATEDPATH HTTP::host $MATCHHOST HTTP::uri $UPDATEDPATH } }- NathPras3 years ago
Cirrus
Hi Kevin,
I used the first iRule provided by you but seems it is not working. Here is how I used it.
Syntax API URL: https://{host}/{base-or-context-path}/{resource-path}. Here resource path as per customer could be anything so when we are rewriting they only care
about to rewrite https://{host}/{base-or-context-path} and rest of the respurce path can be passed as a string to next VIP. So I used your guidance as following :-URL at Akana :- https:/api-tint.blah.com/akana-mulesoft-routing-poc/{anything will return 200 OK}
URL at Mulesoft :- https://np.api.us.test.cnb/akana-mulesoft-routing-poc/{anything will return 200 OK}
1. Crate a Data-group Like following :-ltm data-group internal url_datagroup {
records {
https:/api-tint.blah.com:/akana-mulesoft-routing-poc {
data https://np.api.us.test.cnb:/akana-mulesoft-routing-poc
}
}
type string
}
Note :- here we can add more matching before "type sting" as the list grows.2. Create an iRule like following and attach it to Akana non-prod VIP (10.10.10.10)
when HTTP_REQUEST {
if { [set match [class match -value -- "[HTTP::host]:[HTTP::uri]" equals url_datagroup]] ne "" } {
log local0. "match = $match"
set matchlist [split $match ":"]
log local0. "match host = [lindex $matchlist 0]"
log local0. "match uri = [lindex $matchlist 1]"
HTTP::host [lindex $matchlist 0]
HTTP::uri [lindex $matchlist 1]
}
}
But when a user is calling the Akana API with the help of the above list it should go to Mulesoft as we are rewriting the https://{host}/{base-or-context-path} but unfortuntaley it is landing on Akana itself not getting directed to Mulesoft. Interseting thing is iRule is taking the hit as we can see in statistics and also there is no error is showing while the iRule is getting the hit.- NathPras3 years ago
Cirrus
Attaching Mulesoft snap
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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