Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💡Feature Request: Implement API for Dynamic Tunnel Management in cloudflared #1419

Open
mlanies opened this issue Feb 20, 2025 · 0 comments
Labels
Priority: Normal Minor issue impacting one or more users Type: Feature Request A big idea that would be split into smaller pieces

Comments

@mlanies
Copy link

mlanies commented Feb 20, 2025

Describe the Feature You’d Like

I propose adding a dedicated API or extending the CLI interface to support dynamic management of tunnels through cloudflared access tcp. This feature would allow external applications and orchestration tools to programmatically:
1.Start tunnels dynamically by specifying a hostname and target URL.
2.Monitor tunnel status in real-time, including health checks and error reporting.
3.Gracefully terminate tunnels remotely for proper resource management and secure shutdowns.
4.Retrieve tunnel connection details for enhanced logging and integration with external monitoring systems.

Describe Alternatives You’ve Considered

Currently, the only method for managing tunnels is through direct system command execution (e.g., cloudflared access tcp --hostname --url). This approach presents several key limitations:

  • ❌ No proper error handling: Capturing tunnel-related errors effectively via CLI commands is challenging.
  • ❌ Limited lifecycle management: There’s no built-in method for stopping or restarting tunnels gracefully without terminating the entire process.
  • ❌ No monitoring capabilities: It’s not possible to programmatically retrieve tunnel health status, logs, or connection metrics.

Why This Feature Is Important

A dedicated API would unlock several important benefits:

  • ✅ Seamless integration with orchestration tools (e.g., Kubernetes, Docker Swarm).
  • ✅ Automated tunnel management for CI/CD pipelines.
  • ✅ Enhanced security through more granular control over tunnel sessions.
  • ✅ Easier integration for external applications requiring dynamic tunnel creation.

Additional Security Features Request

It would be highly beneficial if the new API supported encrypted hostname transmission. This could be achieved by:

  • Accepting encrypted hostnames from external sources.
  • Integrating with securely stored encryption keys (local or cloud-based).
  • Allowing the use of temporary encrypted tokens to improve DNS request privacy.

This would help hide DNS connection details and significantly enhance security, especially in Zero Trust environments.

Possible Implementation Ideas

  1. REST API Endpoints
Method Endpoint Description
POST /api/tunnel/start Start a tunnel with provided parameters
GET /api/tunnel/status/{id} Fetch the current status of a specific tunnel
DELETE /api/tunnel/stop/{id} Securely close a specific tunnel
  1. Extended CLI Commands
cloudflared tunnel start --hostname {hostname} --url {url} --secure
cloudflared tunnel status --id {tunnel_id}
cloudflared tunnel stop --id {tunnel_id}

Additional Context

Adding an API for managing cloudflared tunnels programmatically would enable better integration with:

  • Orchestration tools (e.g., Kubernetes, Docker Swarm).
  • Automated deployment pipelines.
  • Monitoring systems for tunnel health and status tracking.
  • Simplified integration with external applications relying on dynamic tunnel creation.

Use Cases

  • Automatically launching secure tunnels during application deployment.
  • Allowing on-demand secure access for specific users or systems.
  • Integrating with monitoring tools like Prometheus for real-time status tracking.
  • Providing secure API access for external developers integrating with cloudflared.

Final Thoughts

Implementing an API for tunnel management would significantly enhance cloudflared by enabling dynamic integration into modern infrastructure stacks. This feature would allow:

  • Streamlined automation workflows
  • Improved resource management
  • Enhanced security for sensitive data transmission

Thank you for considering this request! I look forward to your feedback and hope to see this feature implemented soon.

Thank you for considering this feature request! ⭐️

@mlanies mlanies added Priority: Normal Minor issue impacting one or more users Type: Feature Request A big idea that would be split into smaller pieces labels Feb 20, 2025
@mlanies mlanies changed the title 💡Feature Request: Add API for launching tunnel via cloudflared access tcp 💡Feature Request: Implement API for Dynamic Tunnel Management in cloudflared Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Normal Minor issue impacting one or more users Type: Feature Request A big idea that would be split into smaller pieces
Projects
None yet
Development

No branches or pull requests

1 participant