Application Delivery (ADX)

Reference: Using offset command

by pmorrissey on ‎06-11-2009 11:30 AM (123 Views)

Summary

This reference wiki describes the usage and operation of offset and neg-offset function in rules/policies to assist in rewrite (transformation) and persist policy operations

Typically, a rule is used to match certain string/content (e.g. string in URL or value in header field) in order to perform a rewrite or persist policy operation. If the match was successful, a rewrite/persist string begins after the matched content. This is equivalent to offset 0 and offset 0 is assumed if not specified. If you want to move the starting point for rewrite/persist to another point, use the offset and neg-offset commands.


Specifics

rewrite insert: If you want to move the starting point for rewrite insert operations, use the offset/neg-offset <value> operation

rewrite delete: If you want to move the starting point for rewrite delete operation and specify how many bytes/character should be deleted, use the offset/neg-offset <value> <length> operation

persist: If you want to specify which characters/bytes should be used for persistence string,  use the offset/neg-offset <value> <length> operation

In the case of an 'exists' , 'pattern', 'equals' operator, the offset begins at the end of the value.

Sample HTTP Request:

GET /abc/xyz/index.html HTTP/1.1\r\n

Host: www.abc.foo.com\r\n

Rewrite Examples on HTTP requests using offset

#1

rewrite GET /abc/xyz/index.html => GET "/abc/app2/xyz/index.html

csw-rule r1 url prefix /abc/

!

..

match r1 rewrite request-insert app2/

No offset is specified so insert of "app2/" begins after "/abc/" in the URL. (No offset specified, offset = 0)


#2

rewrite GET /abc/xyz/index.html => GET /abc/xyz/spart/index.html

csw-rule r1 url prefix /abc/

!

..

match r1 rewrite request-insert /spart offset 3

offset 3 specifies to start rewrite at 3 extra bytes/characters after '/abc/" which counts "xyz" so insert of "/spart" begins after "xyz" and before /index


#3

rewrite Host: www.abc.foo.com => Host: www.abc.foo.com:81

csw-rule r2 header Host suffix com

!

..

match r2 rewrite request-insert :81

No offset specified, So, insert begins after .com

The original "Host" header becomes : www.abc.foo.com:81


#4

rewrite GET /abc/xyz/srv2default_index.html => GET /abc/xyz/default_index.html

csw-rule r1 url pattern "srv2default_"

!

..

match r1 rewrite request-delete neg-offset 12 4
Neg-offset 12 specifics to start rewrite delete 12 character back from "_" which means after "xyz/" and length 4 specifices to remove the following 4 characters "srv2" .