CloudProxy provides a comprehensive REST API for managing proxy servers across multiple cloud providers.
First, start CloudProxy with Docker:
docker run -d --name cloudproxy \
-e PROXY_USERNAME='user' \
-e PROXY_PASSWORD='pass' \
-e DIGITALOCEAN_ENABLED=True \
-e DIGITALOCEAN_ACCESS_TOKEN='your_token' \
-p 8000:8000 \
laffin/cloudproxy:latestThen access the API:
# Get a random proxy
curl -X 'GET' 'http://localhost:8000/random' -H 'accept: application/json'
# List all proxies
curl -X 'GET' 'http://localhost:8000/' -H 'accept: application/json'
# Check health status
curl -X 'GET' 'http://localhost:8000/health' -H 'accept: application/json'Access the interactive API documentation at http://localhost:8000/docs. The Swagger UI provides:
- Interactive endpoint testing
- Request/response examples
- Schema definitions
- Authentication details
- Real-time API exploration
When running CloudProxy in Docker:
- From host machine:
http://localhost:8000 - From other containers:
http://cloudproxy:8000(use container name) - From external clients:
http://your-server-ip:8000
Example Docker network setup:
# Create a network for your services
docker network create proxy-network
# Run CloudProxy on the network
docker run -d --name cloudproxy \
--network proxy-network \
-p 8000:8000 \
--env-file .env \
laffin/cloudproxy:latest
# Other containers can access it at http://cloudproxy:8000
docker run --network proxy-network alpine \
wget -qO- http://cloudproxy:8000/randomAll API responses follow a standardized format that includes:
{
"metadata": {
"request_id": "123e4567-e89b-12d3-a456-426614174000",
"timestamp": "2024-02-24T08:00:00Z"
}
}{
"ip": "192.168.1.1",
"port": 8899,
"auth_enabled": true,
"url": "http://username:password@192.168.1.1:8899",
"provider": "digitalocean",
"instance": "default",
"display_name": "My DigitalOcean Instance"
}{
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1",
"instances": {
"default": {
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1"
},
"second-account": {
"enabled": true,
"ips": ["192.168.1.3", "192.168.1.4"],
"scaling": {
"min_scaling": 1,
"max_scaling": 3
},
"size": "s-1vcpu-1gb",
"region": "nyc1"
}
}
}{
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1",
"display_name": "My DigitalOcean Instance"
}GET /?offset=0&limit=10- Supports pagination with offset and limit parameters
- Response format:
{
"metadata": { ... },
"total": 5,
"proxies": [
{
"ip": "192.168.1.1",
"port": 8899,
"auth_enabled": true,
"url": "http://username:password@192.168.1.1:8899",
"provider": "digitalocean",
"instance": "default",
"display_name": "My DigitalOcean Instance"
}
]
}GET /random- Returns a single random proxy from the available pool
- Response format:
{
"metadata": { ... },
"message": "Random proxy retrieved successfully",
"proxy": {
"ip": "192.168.1.1",
"port": 8899,
"auth_enabled": true,
"url": "http://username:password@192.168.1.1:8899",
"provider": "digitalocean",
"instance": "default",
"display_name": "My DigitalOcean Instance"
}
}DELETE /destroy?ip_address={ip}- Removes a specific proxy from the pool
- Response format:
{
"metadata": { ... },
"message": "Proxy scheduled for deletion",
"proxy": {
"ip": "192.168.1.1",
"port": 8899,
"auth_enabled": true,
"url": "http://username:password@192.168.1.1:8899"
}
}GET /destroy- Returns list of proxies scheduled for deletion
- Response format matches List Available Proxies
DELETE /restart?ip_address={ip}- Restarts a specific proxy instance
- Response format matches Remove Proxy response
GET /restart- Returns list of proxies scheduled for restart
- Response format matches List Available Proxies
GET /health- Returns the health status of the CloudProxy service
- Response format:
{
"status": "healthy",
"timestamp": "2024-02-24T08:00:00Z"
}GET /auth- Returns the current authentication configuration
- Response format:
{
"metadata": { ... },
"auth": {
"username_configured": true,
"password_configured": true,
"only_host_ip": false,
"host_ip": "192.168.1.100"
}
}GET /providers- Returns configuration and status for all providers, including all instances
- Response format:
{
"metadata": { ... },
"providers": {
"digitalocean": {
"enabled": true,
"ips": ["192.168.1.1"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1",
"instances": {
"default": {
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1"
},
"second-account": {
"enabled": true,
"ips": ["192.168.1.3", "192.168.1.4"],
"scaling": {
"min_scaling": 1,
"max_scaling": 3
},
"size": "s-1vcpu-1gb",
"region": "nyc1"
}
}
},
"aws": { ... }
}
}GET /providers/{provider}- Returns detailed information for a specific provider, including all instances
- Response format:
{
"metadata": { ... },
"message": "Provider 'digitalocean' configuration retrieved successfully",
"provider": {
"enabled": true,
"ips": ["192.168.1.1"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1"
},
"instances": {
"default": {
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1"
},
"second-account": {
"enabled": true,
"ips": ["192.168.1.3", "192.168.1.4"],
"scaling": {
"min_scaling": 1,
"max_scaling": 3
},
"size": "s-1vcpu-1gb",
"region": "nyc1"
}
}
}PATCH /providers/{provider}- Updates the target proxy count for the default instance of a provider
- Request body:
{
"min_scaling": 2, // Target number of proxies to maintain
"max_scaling": 5 // Reserved for future use (must be >= min_scaling)
}- Response format matches Get Provider Details
- Note: Currently only
min_scalingaffects proxy deployment. The system maintains exactly this number of proxies.
GET /providers/{provider}/{instance}- Returns detailed information for a specific instance of a provider
- Response format:
{
"metadata": { ... },
"message": "Provider 'digitalocean' instance 'default' configuration retrieved successfully",
"provider": "digitalocean",
"instance": "default",
"config": {
"enabled": true,
"ips": ["192.168.1.1", "192.168.1.2"],
"scaling": {
"min_scaling": 2,
"max_scaling": 5
},
"size": "s-1vcpu-1gb",
"region": "lon1",
"display_name": "My DigitalOcean Instance"
}
}PATCH /providers/{provider}/{instance}- Updates the target proxy count for a specific instance of a provider
- Request body:
{
"min_scaling": 2, // Target number of proxies to maintain
"max_scaling": 5 // Reserved for future use (must be >= min_scaling)
}- Response format matches Get Provider Instance Details
- Note: Currently only
min_scalingaffects proxy deployment. The system maintains exactly this number of proxies.
All error responses follow a standard format:
{
"metadata": {
"request_id": "123e4567-e89b-12d3-a456-426614174000",
"timestamp": "2024-02-24T08:00:00Z"
},
"error": "ValidationError",
"detail": "Invalid IP address format"
}| Status Code | Description | Example |
|---|---|---|
| 200 | Success | Request completed successfully |
| 400 | Bad Request | Invalid request parameters |
| 404 | Not Found | Proxy IP or provider not found |
| 422 | Validation Error | Invalid input data format |
| 500 | Internal Server Error | Server-side error |
| 503 | Service Unavailable | CloudProxy service is starting up |
import requests
try:
response = requests.get("http://localhost:8000/random")
response.raise_for_status()
proxy = response.json()["proxy"]
except requests.HTTPError as e:
if e.response.status_code == 404:
print("No proxies available")
elif e.response.status_code == 503:
print("Service is starting up, please wait")
else:
print(f"API error: {e.response.json()['detail']}")
except requests.ConnectionError:
print("Cannot connect to CloudProxy API")The CloudProxy API itself doesn't require authentication for accessing endpoints.
The proxy servers themselves use basic authentication configured via environment variables:
- Basic Auth: Set
PROXY_USERNAMEandPROXY_PASSWORD - IP-based Auth: Set
ONLY_HOST_IP=Trueto restrict access to the host server IP - Combined Auth: Use both username/password and IP restriction for maximum security
Example proxy URL with authentication:
http://username:password@proxy-ip:8899
Currently, CloudProxy API endpoints do not implement rate limiting. However:
- Cloud provider APIs may have their own rate limits
- Proxy creation is naturally limited by the scheduler (runs every 30 seconds)
- Bulk operations should be batched responsibly
CloudProxy allows cross-origin requests from any origin by default. In production environments, you may want to restrict this using a reverse proxy or API gateway.
- API Examples with Code - Detailed examples in multiple languages
- Python Package Usage - Using CloudProxy as a Python library
- Provider Configuration - Setting up cloud providers