vps

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hostinger VPS

Hostinger VPS

The VPS API provides comprehensive management of virtual private servers — from purchasing and setup to Docker deployments, firewall configuration, SSH keys, backups, snapshots, OS reinstallation, recovery mode, malware scanning, and performance monitoring.
VPS API 提供虚拟专用服务器的全面管理功能——从购买、设置到 Docker 部署、防火墙配置、SSH 密钥管理、备份、快照、操作系统重装、恢复模式、恶意软件扫描以及性能监控。

Table of Contents

目录

Core Concepts

核心概念

Virtual Machines

虚拟机

VPS instances with dedicated CPU, RAM, disk, and network resources. Each VM has an OS template, root access, and an IP address. VMs go through states:
initial
running
stopped
.
具备专用CPU、内存、磁盘和网络资源的VPS实例。每个虚拟机都有操作系统模板、root权限和IP地址。虚拟机的状态流程为:
initial
running
stopped

Actions

操作

Asynchronous operations on VMs (start, stop, restart, recreate, etc.) return an action resource with a status you can poll.
对虚拟机执行的异步操作(启动、停止、重启、重建等)会返回一个操作资源,你可以轮询其状态。

Docker Manager

Docker 管理器

Deploy and manage Docker Compose projects directly on VPS instances. Supports creating projects from
docker-compose.yaml
content or GitHub URLs.
直接在VPS实例上部署和管理Docker Compose项目。支持通过
docker-compose.yaml
内容或GitHub URL创建项目。

Firewalls

防火墙

Network security rules that control inbound traffic. By default, all incoming traffic is dropped — you must explicitly add accept rules. Only one firewall can be active per VM at a time. Changes require manual sync to take effect.
控制入站流量的网络安全规则。默认情况下,所有入站流量都会被拒绝——你必须明确添加允许规则。每个虚拟机同一时间只能激活一个防火墙。规则变更需要手动同步才能生效。

SSH Public Keys

SSH 公钥

SSH keys for authentication. Keys are managed at the account level and attached to specific VMs.
用于身份验证的SSH密钥。密钥在账户级别管理,并附加到特定虚拟机。

OS Templates

操作系统模板

Pre-configured operating system images for VM installation (Ubuntu, Debian, CentOS, etc.) including panel templates (e.g., with cPanel or Plesk).
用于虚拟机安装的预配置操作系统镜像(Ubuntu、Debian、CentOS等),包括面板模板(如带有cPanel或Plesk的模板)。

Post-Install Scripts

安装后脚本

Automation scripts that run after VM installation. Saved to
/post_install
with executable permissions. Output goes to
/post_install.log
. Maximum size: 48KB.
虚拟机安装完成后运行的自动化脚本。脚本会保存到
/post_install
并赋予执行权限,输出内容会写入
/post_install.log
。最大大小为48KB。

Backups & Snapshots

备份与快照

  • Backups: Automatic periodic backups managed by Hostinger
  • Snapshots: User-initiated point-in-time captures. Only one snapshot per VM — creating a new one overwrites the existing one
  • 备份:由Hostinger管理的自动定期备份
  • 快照:用户触发的时间点捕获。每个虚拟机只能有一个快照——创建新快照会覆盖现有快照

Recovery Mode

恢复模式

Boot the VM from a recovery disk image for system rescue. The original disk is mounted at
/mnt
.
从恢复磁盘镜像启动虚拟机以进行系统救援。原始磁盘会挂载在
/mnt
目录。

Malware Scanner (Monarx)

恶意软件扫描器(Monarx)

Optional security tool for malware detection and prevention on VPS instances.
用于VPS实例恶意软件检测和防护的可选安全工具。

Common Patterns

常见模式

Purchase and Setup a VPS

购买并设置VPS

bash
undefined
bash
undefined

Step 1: Get available OS templates

Step 1: Get available OS templates

curl -X GET "https://developers.hostinger.com/api/vps/v1/templates"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/templates"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Step 2: Get available data centers

Step 2: Get available data centers

curl -X GET "https://developers.hostinger.com/api/vps/v1/data-centers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/data-centers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Step 3: Purchase a VPS

Step 3: Purchase a VPS

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'

Step 4: Setup purchased VM (if in initial state)

Step 4: Setup purchased VM (if in initial state)

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/setup"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'

**CLI (hapi):**

```bash
hapi vps vm list
Python SDK:
python
from hostinger_api import Hostinger

client = Hostinger(api_token="YOUR_API_TOKEN")
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/setup"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'

**CLI (hapi):**

```bash
hapi vps vm list
Python SDK:
python
from hostinger_api import Hostinger

client = Hostinger(api_token="YOUR_API_TOKEN")

List all VPS instances

List all VPS instances

vms = client.vps.virtual_machines.list() for vm in vms: print(f"{vm.hostname} - {vm.state} - {vm.ip_address}")

**TypeScript SDK:**

```typescript
import { Hostinger } from "hostinger-api-sdk";

const client = new Hostinger({ apiToken: "YOUR_API_TOKEN" });

const vms = await client.vps.virtualMachines.list();
for (const vm of vms) {
  console.log(`${vm.hostname} - ${vm.state} - ${vm.ipAddress}`);
}
PHP SDK:
php
use Hostinger\Api\HostingerApi;

$client = new HostingerApi('YOUR_API_TOKEN');

$vms = $client->vps->virtualMachines->list();
foreach ($vms as $vm) {
    echo "{$vm->hostname} - {$vm->state} - {$vm->ip_address}\n";
}
vms = client.vps.virtual_machines.list() for vm in vms: print(f"{vm.hostname} - {vm.state} - {vm.ip_address}")

**TypeScript SDK:**

```typescript
import { Hostinger } from "hostinger-api-sdk";

const client = new Hostinger({ apiToken: "YOUR_API_TOKEN" });

const vms = await client.vps.virtualMachines.list();
for (const vm of vms) {
  console.log(`${vm.hostname} - ${vm.state} - ${vm.ipAddress}`);
}
PHP SDK:
php
use Hostinger\Api\HostingerApi;

$client = new HostingerApi('YOUR_API_TOKEN');

$vms = $client->vps->virtualMachines->list();
foreach ($vms as $vm) {
    echo "{$vm->hostname} - {$vm->state} - {$vm->ip_address}\n";
}

VM Lifecycle Operations

虚拟机生命周期操作

bash
undefined
bash
undefined

List all VMs

List all VMs

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Get VM details

Get VM details

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Start VM

Start VM

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/start"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/start"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Stop VM

Stop VM

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/stop"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/stop"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Restart VM

Restart VM

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/restart"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/restart"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Set hostname

Set hostname

curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/hostname"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/hostname"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'

Set root password

Set root password

curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/root-password"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/root-password"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'

Recreate VM (DESTRUCTIVE - all data lost)

Recreate VM (DESTRUCTIVE - all data lost)

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/recreate"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
undefined
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/recreate"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
undefined

Deploy Docker Compose Projects

部署Docker Compose项目

bash
undefined
bash
undefined

List Docker projects on a VM

List Docker projects on a VM

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Deploy from docker-compose.yaml content

Deploy from docker-compose.yaml content

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'

Deploy from GitHub URL

Deploy from GitHub URL

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'

Get project containers and stats

Get project containers and stats

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/containers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/containers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

View project logs (last 300 entries)

View project logs (last 300 entries)

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/logs"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/logs"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Start / Stop / Restart / Update / Delete project

Start / Stop / Restart / Update / Delete project

curl -X POST ".../docker/my-app/start" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/stop" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/restart" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/update" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X DELETE ".../docker/my-app/down" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined
curl -X POST ".../docker/my-app/start" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/stop" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/restart" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X POST ".../docker/my-app/update" -H "Authorization: Bearer $HOSTINGER_API_TOKEN" curl -X DELETE ".../docker/my-app/down" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined

Configure Firewalls

配置防火墙

bash
undefined
bash
undefined

Create a firewall

Create a firewall

curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'

Add rules (default drops all — add accept rules for ports you need)

Add rules (default drops all — add accept rules for ports you need)

curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/rules"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/rules"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'

Activate firewall on a VM

Activate firewall on a VM

curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/activate/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/activate/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Sync firewall after rule changes

Sync firewall after rule changes

curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/sync/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/sync/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined

SSH Key Management

SSH密钥管理

bash
undefined
bash
undefined

Create SSH key

Create SSH key

curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'

Attach key to VM

Attach key to VM

curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys/attach/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys/attach/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'

List keys on a VM

List keys on a VM

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined

Backups and Snapshots

备份与快照

bash
undefined
bash
undefined

List backups

List backups

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Restore a backup (DESTRUCTIVE - overwrites all data)

Restore a backup (DESTRUCTIVE - overwrites all data)

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups/99/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups/99/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Create a snapshot (overwrites existing snapshot)

Create a snapshot (overwrites existing snapshot)

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Get current snapshot

Get current snapshot

curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Restore from snapshot

Restore from snapshot

curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefined

Monitor Performance

监控性能

bash
undefined
bash
undefined

Get VM metrics (CPU, memory, disk, network, uptime)

Get VM metrics (CPU, memory, disk, network, uptime)

API Reference

API参考

Virtual Machines

虚拟机

MethodEndpointDescription
GET
/api/vps/v1/virtual-machines
List all VMs
POST
/api/vps/v1/virtual-machines
Purchase new VM
GET
/api/vps/v1/virtual-machines/{id}
Get VM details
POST
/api/vps/v1/virtual-machines/{id}/setup
Setup purchased VM
POST
/api/vps/v1/virtual-machines/{id}/start
Start VM
POST
/api/vps/v1/virtual-machines/{id}/stop
Stop VM
POST
/api/vps/v1/virtual-machines/{id}/restart
Restart VM
POST
/api/vps/v1/virtual-machines/{id}/recreate
Recreate VM (destructive)
PUT
/api/vps/v1/virtual-machines/{id}/hostname
Set hostname
DELETE
/api/vps/v1/virtual-machines/{id}/hostname
Reset hostname
PUT
/api/vps/v1/virtual-machines/{id}/root-password
Set root password
PUT
/api/vps/v1/virtual-machines/{id}/panel-password
Set panel password
PUT
/api/vps/v1/virtual-machines/{id}/nameservers
Set nameservers
GET
/api/vps/v1/virtual-machines/{id}/metrics
Get metrics
GET
/api/vps/v1/virtual-machines/{id}/public-keys
Get attached SSH keys
GET
/api/vps/v1/virtual-machines/{id}/actions
Get action history
GET
/api/vps/v1/virtual-machines/{id}/actions/{actionId}
Get action details
方法端点描述
GET
/api/vps/v1/virtual-machines
列出所有虚拟机
POST
/api/vps/v1/virtual-machines
购买新虚拟机
GET
/api/vps/v1/virtual-machines/{id}
获取虚拟机详情
POST
/api/vps/v1/virtual-machines/{id}/setup
设置已购买的虚拟机
POST
/api/vps/v1/virtual-machines/{id}/start
启动虚拟机
POST
/api/vps/v1/virtual-machines/{id}/stop
停止虚拟机
POST
/api/vps/v1/virtual-machines/{id}/restart
重启虚拟机
POST
/api/vps/v1/virtual-machines/{id}/recreate
重建虚拟机(破坏性操作)
PUT
/api/vps/v1/virtual-machines/{id}/hostname
设置主机名
DELETE
/api/vps/v1/virtual-machines/{id}/hostname
重置主机名
PUT
/api/vps/v1/virtual-machines/{id}/root-password
设置root密码
PUT
/api/vps/v1/virtual-machines/{id}/panel-password
设置面板密码
PUT
/api/vps/v1/virtual-machines/{id}/nameservers
设置域名服务器
GET
/api/vps/v1/virtual-machines/{id}/metrics
获取指标数据
GET
/api/vps/v1/virtual-machines/{id}/public-keys
获取已附加的SSH密钥
GET
/api/vps/v1/virtual-machines/{id}/actions
获取操作历史
GET
/api/vps/v1/virtual-machines/{id}/actions/{actionId}
获取操作详情

Docker Manager (experimental)

Docker管理器(实验性)

MethodEndpointDescription
GET
.../docker
List projects
POST
.../docker
Create project
GET
.../docker/{name}
Get project contents
GET
.../docker/{name}/containers
Get containers with stats
GET
.../docker/{name}/logs
Get project logs (last 300)
POST
.../docker/{name}/start
Start project
POST
.../docker/{name}/stop
Stop project
POST
.../docker/{name}/restart
Restart project
POST
.../docker/{name}/update
Update project
DELETE
.../docker/{name}/down
Delete project (irreversible)
方法端点描述
GET
.../docker
列出项目
POST
.../docker
创建项目
GET
.../docker/{name}
获取项目内容
GET
.../docker/{name}/containers
获取容器及统计数据
GET
.../docker/{name}/logs
获取项目日志(最近300条)
POST
.../docker/{name}/start
启动项目
POST
.../docker/{name}/stop
停止项目
POST
.../docker/{name}/restart
重启项目
POST
.../docker/{name}/update
更新项目
DELETE
.../docker/{name}/down
删除项目(不可恢复)

Firewall

防火墙

MethodEndpointDescription
GET
/api/vps/v1/firewall
List firewalls
POST
/api/vps/v1/firewall
Create firewall
GET
/api/vps/v1/firewall/{id}
Get firewall details
DELETE
/api/vps/v1/firewall/{id}
Delete firewall
POST
/api/vps/v1/firewall/{id}/rules
Create rule
PUT
/api/vps/v1/firewall/{id}/rules/{ruleId}
Update rule
DELETE
/api/vps/v1/firewall/{id}/rules/{ruleId}
Delete rule
POST
/api/vps/v1/firewall/{id}/activate/{vmId}
Activate on VM
POST
/api/vps/v1/firewall/{id}/deactivate/{vmId}
Deactivate on VM
POST
/api/vps/v1/firewall/{id}/sync/{vmId}
Sync rules to VM
方法端点描述
GET
/api/vps/v1/firewall
列出防火墙
POST
/api/vps/v1/firewall
创建防火墙
GET
/api/vps/v1/firewall/{id}
获取防火墙详情
DELETE
/api/vps/v1/firewall/{id}
删除防火墙
POST
/api/vps/v1/firewall/{id}/rules
创建规则
PUT
/api/vps/v1/firewall/{id}/rules/{ruleId}
更新规则
DELETE
/api/vps/v1/firewall/{id}/rules/{ruleId}
删除规则
POST
/api/vps/v1/firewall/{id}/activate/{vmId}
在虚拟机上激活防火墙
POST
/api/vps/v1/firewall/{id}/deactivate/{vmId}
在虚拟机上停用防火墙
POST
/api/vps/v1/firewall/{id}/sync/{vmId}
将规则同步到虚拟机

SSH Keys, Templates, Scripts, Backups, Snapshots, Recovery, PTR, Malware

SSH密钥、模板、脚本、备份、快照、恢复、PTR、恶意软件

MethodEndpointDescription
GET/POST/DELETE
/api/vps/v1/public-keys
Manage SSH keys
POST
/api/vps/v1/public-keys/attach/{vmId}
Attach keys to VM
GET
/api/vps/v1/templates
List OS templates
GET
/api/vps/v1/templates/{id}
Get template details
GET/POST/PUT/DELETE
/api/vps/v1/post-install-scripts
Manage scripts
GET
/api/vps/v1/data-centers
List data centers
GET
.../backups
List backups
POST
.../backups/{id}/restore
Restore backup
GET/POST/DELETE
.../snapshot
Manage snapshot
POST
.../snapshot/restore
Restore snapshot
POST/DELETE
.../recovery
Start/stop recovery mode
POST/DELETE
.../ptr/{ipId}
Manage PTR records
GET/POST/DELETE
.../monarx
Manage malware scanner
方法端点描述
GET/POST/DELETE
/api/vps/v1/public-keys
管理SSH密钥
POST
/api/vps/v1/public-keys/attach/{vmId}
将密钥附加到虚拟机
GET
/api/vps/v1/templates
列出操作系统模板
GET
/api/vps/v1/templates/{id}
获取模板详情
GET/POST/PUT/DELETE
/api/vps/v1/post-install-scripts
管理脚本
GET
/api/vps/v1/data-centers
列出数据中心
GET
.../backups
列出备份
POST
.../backups/{id}/restore
恢复备份
GET/POST/DELETE
.../snapshot
管理快照
POST
.../snapshot/restore
从快照恢复
POST/DELETE
.../recovery
启动/停止恢复模式
POST/DELETE
.../ptr/{ipId}
管理PTR记录
GET/POST/DELETE
.../monarx
管理恶意软件扫描器

Best Practices

最佳实践

Security

安全

  • Always attach SSH keys and disable password auth when possible
  • Configure firewalls — default drops all traffic, add only needed ports
  • Sync firewalls after any rule change — changes don't auto-apply
  • Only one firewall per VM — plan rules in a single firewall
  • Install Monarx malware scanner on production servers
  • Use strong passwords (12+ chars, mixed case, numbers, not leaked)
  • 尽可能始终附加SSH密钥并禁用密码认证
  • 配置防火墙——默认拒绝所有流量,仅添加所需端口的规则
  • 同步防火墙:规则变更后必须手动同步,变更不会自动生效
  • 每个虚拟机只能有一个防火墙——将所有规则规划到单个防火墙中
  • 在生产服务器上安装Monarx恶意软件扫描器
  • 使用强密码(12个字符以上,包含大小写、数字,未泄露过)

Backups & Recovery

备份与恢复

  • Take a snapshot before destructive operations (recreate, major changes)
  • Remember: creating a new snapshot overwrites the existing one
  • Backup restores overwrite all data on the VM
  • Use recovery mode for filesystem repair — original disk is at
    /mnt
  • 在执行破坏性操作(重建、重大变更)之前创建快照
  • 注意:创建新快照会覆盖现有快照
  • 恢复备份会覆盖虚拟机上的所有数据
  • 使用恢复模式修复文件系统——原始磁盘位于
    /mnt

Docker

Docker

  • Docker Manager endpoints are experimental — expect changes
  • GitHub URLs auto-resolve to
    docker-compose.yaml
    in master branch
  • Deploying a project with an existing name replaces it
  • Use logs endpoint for debugging container issues
  • Docker管理器端点为实验性——可能会有变更
  • GitHub URL会自动解析到master分支中的
    docker-compose.yaml
  • 部署同名项目会替换现有项目
  • 使用日志端点排查容器问题

Performance

性能

  • Monitor metrics to right-size your VPS plan
  • Set custom nameservers only if you know what you're doing — wrong config breaks DNS resolution
  • 监控指标以调整VPS套餐规格
  • 仅在了解操作影响的情况下设置自定义域名服务器——错误配置会导致DNS解析失败

Post-Install Scripts

安装后脚本

  • Maximum script size: 48KB
  • Script runs as
    /post_install
    , output goes to
    /post_install.log
  • Test scripts on non-production VMs first
  • 脚本最大大小为48KB
  • 脚本以
    /post_install
    运行,输出写入
    /post_install.log
  • 先在非生产虚拟机上测试脚本

Troubleshooting

故障排查

VM Not Starting

虚拟机无法启动

  • Check action history for error details
  • VM may be in recovery mode — stop recovery first
  • Check if VM is in
    initial
    state — run setup first
  • 查看操作历史获取错误详情
  • 虚拟机可能处于恢复模式——先停止恢复模式
  • 检查虚拟机是否处于
    initial
    状态——先执行设置操作

Cannot SSH Into VM

无法通过SSH连接到虚拟机

  • Verify SSH key is attached (not just in account)
  • Check firewall allows port 22
  • Verify firewall is synced after rule changes
  • Try root password login to diagnose
  • 验证SSH密钥已附加到虚拟机(而不仅仅是在账户中)
  • 检查防火墙是否允许22端口
  • 验证规则变更后防火墙已同步
  • 尝试使用root密码登录以诊断问题

Firewall Rules Not Taking Effect

防火墙规则未生效

  • Rules require manual sync after changes:
    POST .../firewall/{id}/sync/{vmId}
  • Only one firewall can be active per VM
  • Default policy is DROP — ensure accept rules exist for needed ports
  • 规则变更后需要手动同步
    POST .../firewall/{id}/sync/{vmId}
  • 每个虚拟机只能激活一个防火墙
  • 默认策略为拒绝(DROP)——确保为所需端口添加了允许规则

Docker Project Not Starting

Docker项目无法启动

  • Check project logs:
    GET .../docker/{name}/logs
  • Verify docker-compose.yaml is valid
  • Ensure required ports are not already in use
  • Check VM has enough resources (CPU, RAM, disk)
  • 查看项目日志:
    GET .../docker/{name}/logs
  • 验证docker-compose.yaml是否有效
  • 确保所需端口未被占用
  • 检查虚拟机是否有足够资源(CPU、内存、磁盘)

Password Rejected During Recreate

重建时密码被拒绝

  • Must be 12+ characters with uppercase, lowercase, and numbers
  • Password is checked against leaked password databases
  • Try a completely unique, complex password
  • 密码必须包含12个以上字符,且包含大写、小写和数字
  • 密码会与泄露密码数据库进行比对
  • 尝试使用完全唯一的复杂密码

Action Stuck in Progress

操作卡在进行中

  • Poll action status:
    GET .../actions/{actionId}
  • Some operations take several minutes (recreate, backup restore)
  • If stuck for extended time, contact support
  • 轮询操作状态:
    GET .../actions/{actionId}
  • 部分操作需要几分钟时间(重建、恢复备份)
  • 如果长时间卡住,请联系支持人员

See Also

另请参阅

The following deep-dive guides are available in this skill directory:
  • deployment-workflow.md
    — SSH-first deployment workflow for Dockerized apps (7-step process, rollback strategy, verification levels)
  • docker-patterns.md
    — Docker Compose deployment patterns (WordPress, Node+Redis+Postgres, Traefik SSL, lifecycle management)
  • firewall-patterns.md
    — Common firewall configurations (web server, database, Docker host, mail server, TypeScript/PHP examples)
  • terraform-examples.md
    — Infrastructure as Code with the Hostinger Terraform Provider (VPS provisioning, SSH keys, firewalls, complete infra example)
本技能目录中提供了以下深入指南:
  • deployment-workflow.md
    —— 面向Docker化应用的SSH优先部署工作流(7步流程、回滚策略、验证级别)
  • docker-patterns.md
    —— Docker Compose部署模式(WordPress、Node+Redis+Postgres、Traefik SSL、生命周期管理)
  • firewall-patterns.md
    —— 常见防火墙配置(Web服务器、数据库、Docker主机、邮件服务器、TypeScript/PHP示例)
  • terraform-examples.md
    —— 使用Hostinger Terraform Provider实现基础设施即代码(VPS配置、SSH密钥、防火墙、完整基础设施示例)

References

参考资料