Child pages
  • Add HTTP CDN Resource
Skip to end of metadata
Go to start of metadata

To create an HTTP resource, use the following request:

POST /cdn_resources.xml
POST /cdn_resources.json

Add HTTP PULL XML Request example

curl -i -X POST -d '<cdn_resource><cdn_hostname>cdn.test.co</cdn_hostname><cdn_ssl_certificate_id>ssl_sert_id</cdn_ssl_certificate_id><edge_group_ids type="array"><edge_group_id type="integer">1</edge_group_id></edge_group_ids><resource_type>HTTP_PULL</resource_type><origin>test.origin.com</origin></cdn_resource>' -u user:userpass http://onapp.test/cdn_resources.xml -H 'Accept: application/xml' -H 'Content-type: application/xml' 

Add HTTP PULL JSON Request example

curl -i -u user:userpass -X POST http://onapp.test/cdn_resources.json -H 'Accept: application/json' -H 'Content-type: application/json' -d '{"cdn_resource":{"cdn_hostname":"cdn.test.co","resource_type":"HTTP_PULL","cdn_ssl_certificate_id":"ssl_cert_id","edge_group_ids":[1],"origin":"test.origin.com"}}'

Add HTTP PUSH XML Request example

curl -i -X POST -d '<cdn_resource><cdn_hostname>cdn.test.co</cdn_hostname><cdn_ssl_certificate_id>ssl_sert_id</cdn_ssl_certificate_id><edge_group_ids type="array"><edge_group_id type="integer">7</edge_group_id></edge_group_ids><resource_type>HTTP_PUSH</resource_type><ftp_password>j3x8svqybA2gmrgYOZSrOlYToQ</ftp_password></cdn_resource>' -u user:userpass http://onapp.test/cdn_resources.xml -H 'Accept: application/xml' -H 'Content-type: application/xml' 

Add HTTP PUSH JSON Request example

curl -i -u user:userpass -X POST http://onapp.test/cdn_resources.json -H 'Accept: application/json' -H 'Content-type: application/json' -d '{"cdn_resource":{"cdn_hostname":"cdn.test.co","resource_type":"HTTP_PUSH","cdn_ssl_certificate_id":"ssl_cert_id","edge_group_ids":[7],"ftp_password":"j3x8svqybA2gmrgYOZSrOlYToQ"}}'


Where:

(lightbulb) origin* - the path from which the CDN requests the content. You can specify up to 3 origins. You can specify custom origin port (for HTTP pull resource only). To use the custom port for resource's origin, specify a port number using a colon (":"). For example, <origin>1.2.3.4:80</origin>.

When you are specifying only one origin, it can be either a CDN hostname or an IP address. In case you are specifying more than one origin, they can only be IP addresses.

To send two or more origins in the API request, use array:

XML example

<origins type="array">
    <origin>111.111.11.111</origin>
    <origin>111.111.11.111</origin>
</origins>

JSON example

{"origins":["111.111.11.111", "222.222.22.222"]}

cdn_hostname * - indicate the hostname which will serve static content. Specify the following fourth-level domain name for this parameter to create a resource with SSL enabled: "example.r.worldssl.net", where replace the example with the desired name.

resource_type * - HTTP_PULL or HTTP_PUSH

(lightbulb)cdn_ssl_certificate_id - the ID of the custom SNI SSL certificate you want to add to the resource. You should only specify the IDs of those certificates that were added by the user with whom the new resource will be associated.

cdn_ssl_certificate_id - the ID of the custom SNI SSL certificate you want to add to the resource

edge_group_ids * - indicate the ID(s) of required CDN edge groups

ftp_password * - specify the FTP password if you add an HTTP PUSH CDN resource type. It can consist of 6-32 alphanumeric characters.

 

Response

You will get a response consisting of two parts - the header with HTTP status code and the response body including the parameters. At this stage some of the parameters can be empty. This is expected behavior, because the full process of creation takes some time, and remote service cannot fill in the parameters at this time. For the complete list of parameters use GET request.

Page history

OnApp 4.0:

  • origin parameter allows adding port to HTTP pull resource.
  • Added cdn_ssl_certificate_id parameter that enables a user to associate a custom SNI SSL certificate with a CDN resource
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels