Jump to content
Welcome to our new Citrix community!

Content Switch vserver with different Backendserver Path


nlffel439

Recommended Posts

Hi,

I have normally always built CS vServers whose path was identical to that of the backend, unfortunately I now have the problem that I have a backend server whose path is not the same as the one I enter in the URL.


Example:

mycompany.com/api ---> backend : 192.168.0.10/
mycompany.com/api/dir1 --> Backend: 192.168.0.10/dir1

how can I solve this best, I can't get any further when configuring the required policy :( 

Many greetings 

Nino

 

Link to comment
Share on other sites

Content Switching to LB Vserver and then REWRITE policy to do path corrections  or if more complicated URL Transform. 

 

If its just a simple directory insertion, such as:

http://mycompany.com/api<otherpathstuff> --> http://mycompany.com/api/dir1<otherpathstuff>

Then a simple rewrite will work. If the rewrite varies by content switching decision, do it at the LB vserver level after content switch is done.

 

If you need to do different rewrites for different paths, then you'll need more explicit rewrites instead of one generic one.

 

There are  a couple of ways to do this for just the path element insertion above; but if you need more help post back.  There is more than one way Rewrite can do this.

The first example is based on insert_after action that targets first element of path and then inserts new thing in this position while keeping the rest of the path/query intact:

So, for example path/query string:  GET /app1/demo2/page.cgi?a1=b1&a2=b2 HTTP/1.1

It rewrites it to:  GET /app1/dir1/demo2/page.cgi?a1=b1&a2=b2 HTTP/1.1

 

add rewrite action rw_pol_insertpath insert_after 'http.REQ.URL.PATH.GET(1)' '"/dir1"'
add rewrite policy rw_pol_insertpath '!http.REQ.URL.PATH.get(2).EQ("dir1")' rw_pol_insertpath

 

Quick explanation of http.req.url.path.get(<int>)

For a sample URL: http://demo.mycompany.com/api/subdir/somepage.cgi?a1=b1&a2=b2

http.req.url.path matches:  /api/subdir/somepage.cgi

http.req.url.path.get(1) matches:   api    # aka first element of path between slash1 and slash2.  NOTE a lot of operators are 0-based. This one is 1-based in this situation.

http.req.url.path.get(2) matches:  subdir

http.req.url.path.get(3) matches:  somepage.cgi

http.req.url.path.get(4) is not defined in this sample string as this is now query string.

 

So the rewrite is going to insert after path.get(1) which is "api" without any of the slashes ("/") included.

This allows a new hardset string "/dir1" to be inserted while preserving the necessary "/" to preserve a valid url.

 

If you need different path insertions after the CS decision, then bind the rewrite policy to the lb vserver targets after CS is made.

If you have lots of different path insertions needed, then things get more interesting depending on scope.  

 

 

See if this helps you solve your problem.

 

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...