# Cloudflare Tunnel Configuration
# This file is used when running cloudflared without a token (manual setup)
# For token-based setup, the token contains all configuration
# Valores ${VAR} podem ser preenchidos via `envsubst` usando o .env do Models Gateway.

tunnel: vello-models
credentials-file: /etc/cloudflared/credentials.json

# Ingress rules
ingress:
  # Main proxy endpoint
  - hostname: models.agenticca.ai
    path: /vello*
    service: ${CLOUDFLARE_TUNNEL_SERVICE_URL}
    originRequest:
      connectTimeout: 30s
      tcpKeepAlive: 30s
      noHappyEyeballs: false
      keepAliveConnections: 1024
      keepAliveTimeout: 90s
      httpHostHeader: models.agenticca.ai
      originServerName: models.agenticca.ai
      
  # Health check endpoint
  - hostname: models.agenticca.ai
    path: /health
    service: ${CLOUDFLARE_TUNNEL_SERVICE_URL}
    
  # Metrics endpoint (restricted)
  - hostname: models.agenticca.ai
    path: /metrics
    service: ${CLOUDFLARE_TUNNEL_SERVICE_URL}
    originRequest:
      access:
        required: true
        teamName: "admin"
        
  # Catch-all rule
  - service: http_status:404

# Optional: Tunnel metrics
metrics: ${CLOUDFLARE_TUNNEL_METRICS_ADDR:-0.0.0.0:2000}

# Optional: Grace period for shutdown
grace-period: 30s

# Optional: Logging
loglevel: info
logfile: /var/log/cloudflared.log

# Optional: Update auto-update
no-autoupdate: true
