Was this helpful?

 

API Platform Base Path: https://api.enterprise.apigee.com/v1/o/{org_name}

API Resource Path:

/environments/{env_name}/targetservers

Description: Creates a TargetServer in the environment specified

Verb: POST
Auth: Basic Auth
Media types:
application/json
text/xml

 

Overview: Use this method to create TargetServer definitions in an environment. TargetServers are used to decouple TargetEndpoint HTTPTargetConnections from concrete URLs for backend services.

To do so, an HTTPConnection can be configured to use a LoadBalancer that lists one or more 'named' TargetSevers. Using TargetServers, you can create an HTTPTargetConnection that calls a different backend server based on the environment where the API proxy is deployed.

For example, instead of the following configuration:

<TargetEndpoint name="default">
  <HTTPTargetConnection>
    <URL>http://s1.mybackendservice.com</URL>
  </HTTPTargetConnection>
</TargetEndpoint>
You can reference a TargetServer as follows:
<TargetEndpoint name="default">
    <HTTPTargetConnection>
        <LoadBalancer>
            <Server name="target1" />
        </LoadBalancer>
  </HTTPTargetConnection>
</TargetEndpoint>

You can then set up a TargetServer called target1 in the 'test' environment that points to a test backend service, and a different TargetServer called target1 in the 'prod' environment that points to a production backend. When you 'promote' the API proxy with this configuration from the test to the prod environment, the TargetEndpoint will use the appropriate backend service, without requiring any changes in the API proxy configuration.

Sample Request (JSON):

$ curl -X POST -H content-type:application/json \
  -u username:password \
  https://api.enterprise.apigee.com/v1/o/org1/e/prod/targetservers \
  -d '{
    "name" : "target1",
    "host" : "s1.mybackendservice.com",
    "isEnabled" : true,
    "port" : 80
  }'

Sample Request (XML):

$ curl -X POST -H content-type:text/xml -H accept:text/xml \
  -u username:password \
  https://api.enterprise.apigee.com/v1/o/org1/e/prod/targetservers \
  -d '<TargetServer name="target1">
  <Host>s1.mybackendservice.com</Host>
  <Port>80</Port>
  <IsEnabled>true</IsEnabled>
</TargetServer>'
 
Request Payload Elements:
Name Description Default Required?
Name The name of the target server. The characters you are allowed to use in the name are restricted to the following: A-Z0-9._\-$ %. For example, Cat2 %_ is a legal name. N/A Yes
Host The DNS name or IP address of the machine that this TargetServer will refer to. N/A Yes
Port The port on which the backend service is configured to listen. If you don't specify a port, it defaults to zero, which is invalid. If you're not sure, try port 80. 0 Sort of
IsEnabled A boolean (true/false) that determines whether this TargetServer is enabled or not. You can use this setting to take TargetServers out of rotation, without requiring you to delete the TargetServer definition. false No

Sample Response (JSON):

{
  "host" : "s1.mybackendservice.com",
  "isEnabled" : true,
  "name" : "target1",
  "port" : 80
}

Sample Response (XML):

<TargetServer name="target1">
    <IsEnabled>true</IsEnabled>
    <Host>s1.mybackendservice.com</Host>
    <Port>80</Port>
</TargetServer>

TargetServers expose the same SSL configuration settings as TargetEndpoints.

<TargetServer  name="TargetServer 1"> 
    <IsEnabled>true</IsEnabled> 
    <Host>www.example.com/Host> 
    <Port>443</Port> 
    <SSLInfo> 
        <Ciphers/> 
        <ClientAuthEnabled>true</ClientAuthEnabled> 
        <Enabled>true</Enabled> 
        <IgnoreValidationErrors>false</IgnoreValidationErrors> 
        <KeyAlias>keystore-alias</KeyAlias> 
        <KeyStore>keystore-name</KeyStore> 
        <Protocols/> 
        <TrustStore>truststore-name</TrustStore> 
    </SSLInfo> 
</TargetServer > 

For complete instructions on configuring outbound client SSL, see Client-SSL to backend servers.

 

Help or comments?

  • Something's not working: See Apigee Support
  • Something's wrong with the docs: Click Send Feedback in the lower right.
    (Incorrect? Unclear? Broken link? Typo?)