• No results found

Using URL / Host Switching along with Cookie Persistence

The AX device supports use of URL / host switching and cookie persistence in the same SLB configuration. However, to enable this support, you must enable the match-type service-group option in the cookie persistence tem-plate.

By default, the service-group option is disabled in cookie persistence tem-plates. In this case, URL switching or host switching is used only for the initial request from a client. After the initial request, the same service group is always used for subsequent requests from the same client.

To continue using URL switching or host switching to select a service group for each request, enable the service-group option in the cookie persistence template. In this case, for each request from the client, the AX device first selects a service group, then uses information in the cookie to select the real server and port within the service group.

Figure 41 shows an example.

FIGURE 41 URL Switching with Cookie Persistence

In this example, URL switching and cookie persistence are both configured, and the service-group option is enabled in the cookie persistence template.

For each client request, URL switching selects a service group first. Then, after a service group is selected, a real server and port are selected within the service group.

If the client’s request does not have a persistence cookie that includes the selected service group, the AX device uses SLB to select a server, then inserts a persistence cookie into the reply from the server. The cookie includes the service group name.

If the client’s request already has a persistence cookie containing the name of the selected service group, the AX device uses the information in the cookie to select the same server within the service group.

For example, the first time service group sgabc is selected by URL switch-ing, the AX device inserts a cookie into the server's reply, to ensure that the same server is used the next time URL switching selects sgabc. The first time service group sg123 is selected by URL switching, the AX device inserts a second cookie into the server’s reply, to ensure that the same server is used the next time URL switching selects sg123. Even though URL switching does not always select the same service group, the same server within the selected service group is always selected.

Cookie Persistence Match-Type Options

When cookie persistence is configured, the AX device adds a persistence cookie to the server reply before sending the reply to the client. The client’s browser re-inserts the cookie into each request. The format of the cookie depends on the match-type setting:

match-type (port) – This is the default setting. Subsequent requests from the client will be sent to the same real port on the same real server.

URL switching or host switching is used only for the first request.

The cookie that the AX device inserts into the server reply has the fol-lowing format:

Set-Cookie: cookiename-vport=rserverIP_rport

The vport is the virtual port number. The rserverIP is the real server IP address and the rport is the real server port number.

Note: The port option is shown in parentheses because the CLI does not have a

“port” keyword. If you do not set the match type to server (see below), the match type is automatically “port”.

match-type server – Subsequent requests from the client for the same VIP will be sent to the same real server, provided that all virtual ports of the VIP use the same cookie persistence template with match-type set to server. URL switching or host switching is used only for the first request.

The cookie that the AX device inserts into the server reply has the fol-lowing format:

match-type (port) service-group – Subsequent requests from the client will be sent to the same real port on the same real server, within the ser-vice group selected by URL switching or host switching. URL switch-ing or host switchswitch-ing is still used for every request.

The cookie that the AX device inserts into the server reply has the fol-lowing format:

Set-Cookie: cookiename-vport-servicegroupname=rserverIP_rport

match-type server service-group – Subsequent requests from the cli-ent for the same VIP will be scli-ent to the same real server, within the ser-vice group selected by URL switching or host switching. URL

switching or host switching is still used for every request.

The cookie that the AX device inserts into the server reply has the fol-lowing format:

Set-Cookie: cookiename-servicegroupname=rserverIP

Note: For security, address information in the persistence cookies is encrypted.

U

SINGTHE

CLI

To enable the service-group option, use the following command at the con-figuration level for the cookie persistence template:

[no] match-type

{server [service-group] | service-group}

The default granularity is port-level granularity as described above. (There is no port keyword.)

To use the service-group option with port-level granularity, enter the fol-lowing command: match-type service-group

To use the service-group option with server-level granularity, enter the fol-lowing command: match-type server service-group

CLI Example

The following commands configure a cookie persistence template named

“persist-cookie-sg” and enable port-level persistence with support for URL switching or host switching:

AX(config)#slb template persist cookie persist-cookie-sg AX(config-cookie persistence template)#name SGCookie

AX(config-cookie persistence template)#match-type service-group