ADC

API method

You can use the API method to determine the best performing GSLB service. The API method for GSLB uses a REST API to determine the best performing GSLB service.

In the API method, when GSLB receives a DNS request from a client, it evaluates the request against the specified rule. If GSLB encounters the HTTP callout expression, SYS.HTTP_CALLOUT(<name>), it invokes a REST API request to an HTTP callout agent. GSLB uses the response from the HTTP callout agent to decide the best performing service. In the DNS response, GSLB returns the IP address of the best performing service, back to the client.

To configure a GSLB API method by using the CLI

Perform the following to configure the GSLB API method:

  1. Configure an HTTP callout.

    For more information, see Configuring an HTTP callout.

    At the command prompt, type:

    add policy httpCallout <name> [-IPAddress <ip_addr|ipv6_addr>] [-port <port>] [-vServer <string>] [-returnType <returnType>] [-httpMethod (GET | POST)] [-hostExpr <string>] [-urlStemExpr <string>] [-headers <name(value)> ...] [-parameters <name(value)> ...] [-bodyExpr <string>] [-fullReqExpr <string>] [-scheme (http | https)] [-resultExpr <string>] [-cacheForSecs <secs>] [-comment <string>]
    <!--NeedCopy-->
    

    Example:

    add policy httpCallout GSLB_Method_API -IPAddress 208.111.39.237 -port 443 -returnType TEXT -hostExpr “\”hopx.gslb.com\“” -urlStemExpr “\”/zones/1/customers/92395/apps/6/decision\“” -headers Authorization(“Basic 19fbe6db-4332-4e3f-a8bc-ee47bdc726f8") -parameters ip(DNS.REQ.OPT.ECS.IP.TYPECAST_TEXT_T ALT CLIENT.IP.SRC.TYPECAST_TEXT_T) -scheme https -resultExpr “HTTP.RES.BODY(HTTP.RES.CONTENT_LENGTH).XPATH_JSON(xp%/providers/Val[1]/provider%)” -cacheForSecs 30
    <!--NeedCopy-->
    
  2. Specify the API method for load balancing. GSLB evaluates the DNS request against the specified rule.

    At the command prompt, type:

    add gslb vserver <name> <serviceType>  [-lbMethod <lbMethod>] [-backupLBMethod <backupLBMethod>] -rule <expression>
    <!--NeedCopy-->
    

    Example:

    add gslb vserver vs1 HTTP -lbMethod API -backupLBMethod ROUNDROBIN -rule “sys.http_callout(GSLB_Method_API)”
    <!--NeedCopy-->
    

Sample configuration for integrating GSLB and ITM using API as the LB method

This configuration allows GSLB to use the internet visibility aspects of the Citrix intelligent traffic management (ITM) to determine the best performing GSLB service.

/* Enable ns features */

enable ns feature lb gslb cs

/* This is a named expression that is used in the HTTP callout, used for result expression. */

add policy expression exp1 "HTTP.RES.BODY(HTTP.RES.CONTENT_LENGTH).XPATH_JSON(xp%/providers/Val[1]/provider%)"

/* This is a named expression that is used in HTTP callout, used for host expression. */

add policy expression exp2 "\"hopx.cedexis.com\""

/* This is the HTTP callout configured to request the ITM for the GSLB decision. */

add policy httpCallout ITM_OpenMix_API -IPAddress 208.111.39.237 -port 80 -returnType TEXT -hostExpr exp2 -urlStemExpr "\"/zones/1/customers/61770/apps/3/decision\"" -headers Authorization("Basic a310697a-1d69-48bf-8f36-55742a8e894e") -parameters ip(DNS.REQ.OPT.ECS.IP.TYPECAST_TEXT_T ALT CLIENT.IP.SRC.TYPECAST_TEXT_T) -scheme http -resultExpr exp1 -cacheForSecs 30

/* Add service 1 */
add service sg1 98.136.103.24 HTTP 80 -gslb NONE -maxClient 0 -maxReq 0 -cip DISABLED -usip NO -useproxyport YES -sp OFF -cltTimeout 180 -svrTimeout 360 -CKA NO -TCPB NO -CMP NO

/* Add service 2 */
add service sg2 172.217.194.113 HTTP 80 -gslb NONE -maxClient 0 -maxReq 0 -cip DISABLED -usip NO -useproxyport YES -sp OFF -cltTimeout 180 -svrTimeout 360 -CKA NO -TCPB NO -CMP NO

/* Add ADNS service */

add service adns1 10.102.217.106 ADNS 53 -gslb NONE -maxClient 0 -maxReq 0 -cip DISABLED -usip NO -useproxyport NO -sp OFF -cltTimeout 120 -svrTimeout 120 -CKA NO -TCPB NO -CMP NO

/* Add lb vserver 1 for service 1 */
add lb vserver lbvs1 HTTP 10.102.217.116 80 -persistenceType NONE -cltTimeout 180

/* Add lb vserver 2 for service 2 */
add lb vserver lbvs2 HTTP 10.102.217.117 80 -persistenceType NONE -cltTimeout 180

/* Bind service 1 to lb vserver 1 */

bind lb vserver lbvs1 sg1

/* Bind service 2 to lb vserver 2 */

bind lb vserver lbvs2 sg2

/* Configure API GSLB method on GSLB virtual server to call the HTTP callout. This HTTP callout requests the ITM for the GSLB decision and returns GSLB service name, which should serve the request. */

add gslb vserver vs1 HTTP -lbMethod API -backupLBMethod ROUNDROBIN -rule "sys.http_callout(ITM_OpenMix_API)" -tolerance 0 -ECS ENABLED

/* Add GSLB site */

add gslb site site1 10.102.217.106 -publicIP 10.102.217.106

/* Add GSLB service 1 */

add gslb service aws_ec2_ap_south_1_asia_pacific_mumbai_1 10.102.217.116 HTTP 80 -publicIP 10.102.217.116 -publicPort 80 -maxClient 0 -siteName site1 -sitePersistence HTTPRedirect -sitePrefix gs2. -cltTimeout 180 -svrTimeout 360 -downStateFlush ENABLED

/* Add GSLB service 2 */

add gslb service aws_ec2_ap_south_1_asia_pacific_mumbai 10.102.217.117 HTTP 80 -publicIP 10.102.217.117 -publicPort 80 -maxClient 0 -siteName site1 -sitePersistence HTTPRedirect -sitePrefix gs1. -cltTimeout 180 -svrTimeout 360 -downStateFlush ENABLED

/* Bind the GSLB service 1 to GSLB server 1 */
bind gslb vserver vs1 -serviceName aws_ec2_ap_south_1_asia_pacific_mumbai_1

/* Bind the GSLB service 2 to GSLB server 2 */
bind gslb vserver vs1 -serviceName aws_ec2_ap_south_1_asia_pacific_mumbai

/* Bind a domain name to the GSLB virtual server */
bind gslb vserver vs1 -domainName testruchit104.com -TTL 5

<!--NeedCopy-->
API method