# Personal Internet Cell - Caddy Configuration
# This serves as the main reverse proxy and TLS termination point

# Global settings
{
    # Auto-generate certificates for .cell domains
    auto_https disable_redirects
}

# Main cell domain - replace 'mycell' with your cell name
mycell.cell {
    # TLS with internal CA
    tls internal

    # API endpoints
    handle /api/* {
        reverse_proxy cell-api:3000
    }

    # Web UI
    handle / {
        reverse_proxy cell-webui:80
    }

    # Email web interface
    handle /mail {
        reverse_proxy cell-mail:80
    }

    # Calendar and contacts
    handle /calendar {
        reverse_proxy cell-radicale:5232
    }

    # File storage
    handle /files {
        reverse_proxy cell-webdav:80
    }

    # DNS management interface
    handle /dns {
        reverse_proxy cell-dns:8080
    }

    # RainLoop Webmail
    handle_path /webmail/* {
        reverse_proxy cell-rainloop:8888
    }

    # FileGator File Browser
    handle /files-ui* {
        reverse_proxy cell-filegator:8080
    }
}

# Peer cell domains (will be dynamically added)
# Example: bob.cell {
#     reverse_proxy cell-wireguard:51820
# }

# Local development
localhost {
    # API endpoints
    handle /api/* {
        reverse_proxy cell-api:3000
    }

    # Web UI
    handle / {
        reverse_proxy cell-webui:80
    }

    # Email web interface
    handle /mail {
        reverse_proxy cell-mail:80
    }

    # Calendar and contacts
    handle /calendar {
        reverse_proxy cell-radicale:5232
    }

    # File storage
    handle /files {
        reverse_proxy cell-webdav:80
    }

    # DNS management interface
    handle /dns {
        reverse_proxy cell-dns:8080
    }
} 