Virtual Service
A "Virtual Service" is a combination of a Virtual IP (VIP) address and a TCP port, which listens and directs the traffic to the intended service.
To Create a Virtual Service
URL: /v1/virtual_services | |||
Method: POST | |||
Description: Creates a virtual service with the given values. | |||
Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
Input Parameters: |
|
|
|
name | Alphanumeric | Yes | The name of the new service. |
ip_address | Numeric | Yes | The virtual IP address that will be used for accessing this application. |
port | Numeric | Yes | The port number on which your web server responds. |
type | Enumeration | Yes | The type of the service you want to create. The enumerated values include:
|
address_version | Enumeration | Yes | The internet protocol version of the service. The enumerated values include:
|
vsite | Alphanumeric | Optional | The name of the vsite under which the service needs to be created. Note: This field is required ONLY when the service needs to be created under a specific vsite. If not, the service will be created under the default vsite. |
group | Alphanumeric | Optional | The name of the service group under which the service needs to be created. Note: This field is required ONLY when the service needs to be created under a specific service group. If not, the service will be created under the default service group. |
certificate | Alphanumeric | Conditional | The certificate that needs to be presented to the browser when accessing this Service. Note: This is a required parameter ONLY when the service is HTTPS, Instant SSL, Custom SSL or FTP SSL. |
service_hostname | Alphanumeric | Conditional | The domain name to identify and rewrite HTTP requests to HTTPS. Note: This is a required parameter ONLY when the service is Instant SSL. |
Output Parameters: |
|
|
|
id | Alphanumeric |
| The name of the service that got created. |
Example: HTTP Service
Request:
curl http://192.168.0.1:8000/restapi/v1/virtual_services -u 'eyJldCI6IjEnYzYzZTFjIiwidXNlciI6ImFkbWluIn0=\n:' -X POST -H Content-Type:application/json -d '{"name": "demo_service_3", "ip_address": "10.11.16.176", "port": "80", "type":"http", "address_version":"ipv4", "vsite":"demo_vsite", "group":"demo_vsite_group"}'
Response:
{"id":"demo_service_3","token":"eyJldCI6IjEzNzk2ODMxIiwidXNlciI6ImFkbWluIn0=\n"}
Example: HTTPS Service
Request:
curl http://192.168.0.1:8000/restapi/v1/virtual_services -u 'eyJldCI6IjEzxMTEwIiwidXNlciI6ImFkbWluIn0=\n:' -X POST -H Content-Type:application/json –d
'{
"certificate": "cert1",
"address_version": "ipv4",
"name": "demo_service_2",
"type": "https",
"ip_address": "10.11.12.138",
"port": "80"
}'
Response:
{"id":"demo_service_2","token":"eyJldCI6IjTQzODMxIiwidXNlciI6ImFkbWluIn0=\n"}