Skip to main content

Tutorial: How to Secure Access to OpenClaw (AI Agent) with Access Server

Abstract

Secure OpenClaw with OpenVPN Access Server. Deploy the AI gateway, configure VPN routing rules, and restrict access so OpenClaw is reachable only through the VPN.

Overview

This tutorial explains how to secure access to OpenClaw, an AI agent gateway, using Access Server. By routing traffic through Access Server, you can ensure that users can access the OpenClaw service only while connected to the VPN.

In this example scenario:

Brandon, an IT and networking administrator, already uses Access Server in split-tunnel mode to provide employees with secure remote access to private applications. The company now wants to secure access to OpenClaw, ensuring that users can access it only through the VPN.

OpenClaw is an AI agent gateway that connects chat applications (such as WhatsApp, Telegram, Discord, and iMessage) to AI agents like GPT-4o or Claude.

This tutorial shows how to:

  • Deploy OpenClaw.

  • Configure its web gateway.

  • Restrict access using Access Server routing rules.

  • Verify that access works only through the VPN.

Prerequisites

  • Access Server (recommended 3.1.0 or newer to use Domain Routing)

  • OpenClaw deployed (for example, using the DigitalOcean Marketplace)

  • SSH access to your OpenClaw server

  • A VPN client for connecting to Access Server

Note

In our documentation, we use example IPv4 addresses and subnets reserved for documentation, such as 192.0.2.0/24, 198.51.100.0/24, and 203.0.113.0/24.

Ensure you replace them with valid IPv4 addresses and subnets for your network(s).

To deploy OpenClaw, create a new Droplet using the DigitalOcean marketplace:

  1. Sign in to your DigitalOcean account and click Create OpenClaw Droplet.

  2. Select your Droplet plan and data center region.

  3. Select your authentication method.

    Tip

    We recommend using SSH keys for better security.

  4. Configure any optional settings, and click Create Droplet.

Note

This tutorial assumes you use an SSH key pair.

After the Droplet launches, connect to it using SSH.

  1. Open a terminal or SSH client.

  2. Connect to the Droplet using the root user:

    ssh -i /path/key-pair-name.pem1 root@instance-ipv4-address2

    1

    Replace with your private SSH key.

    2

    Replace with your Droplet's public IP address.

    Tip

    You can refer to Connect to Access Server via SSH using PuTTY for steps to connect with the PuTTY SSH client from a Windows computer. If you have a different configuration, please follow DigitalOcean’s instructions on connecting to your instance.

  3. After connecting, the OpenClaw configuration tool runs automatically.

    • You'll see a prompt similar to this:

      --- AI Provider Selector ---
      1) GradientAI
      2) OpenAI
      3) Anthropic
      4) OpenRouter
      5) OpenClaw Model Setup
      Select a provider (1-5):
  4. Choose the AI provider you want to use.

  5. When prompted for an AI model access key:

    • Enter the key if available, or

    • Press Ctrl+C to skip and configure later.

You need to retrieve the OpenClaw gateway token to access the dashboard.

  1. On the OpenClaw server console, grab the gateway token:

    grep OPENCLAW_GATEWAY_TOKEN /opt/openclaw.env
    • Example output:

      OPENCLAW_GATEWAY_TOKEN=ABCDE12345
  2. Copy the token value (for example, ABCDE12345) and store it securely.

You'll use this token later to access the OpenClaw gateway.

The DigitalOcean OpenClaw image includes Caddy, which acts as the web server. Configure it so OpenClaw listens only on the Droplet's private IP address.

  1. Retrieve the Droplet private IP address (in this case, we'll get the one for eth1):

    PRIVATE_IP=$(ip -4 addr show eth1 | grep -o 'inet [0-9.]*' | cut -d' ' -f2)
    • Example private IP:

      192.0.2.5
  2. Edit the Caddy configuration so it listens only on the private IP:

    sudo tee /etc/caddy/Caddyfile > /dev/null <<EOF
    ${PRIVATE_IP} {
        reverse_proxy localhost:18789
        header X-DO-MARKETPLACE "openclaw"
    }
    EOF

Optional: Configure a domain

Instead of using a private IP address, you can use a domain name. This lets you configure Domain Routing in Access Server to use the domain name instead of the IP address. Example domain:

openclaw.example.com
  • Edit the Caddy configuration file to attach a domain name:

    sudo tee /etc/caddy/Caddyfile > /dev/null <<EOF
    <DOMAIN_NAME> {
       tls internal
       reverse_proxy localhost:18789
       header X-DO-MARKETPLACE "openclaw"
    }
    EOF

    Replace <DOMAIN_NAME> with the domain name associated with your OpenClaw Droplet. In our example, our domain is openclaw.example.com.

Verify the OpenClaw service

  1. Check that OpenClaw is listening on port 18789:

    netstat -tulpn | grep 18789
    • Example output:

      tcp        0      0 127.0.0.1:18789         0.0.0.0:*               LISTEN      3376/openclaw-gatew
  2. If netstat isn't installed, install it:

    apt install net-tools

To restrict access to OpenClaw, configure Access Server routing rules so traffic to the OpenClaw host is only available through the VPN.

Important

If your OpenClaw Droplet is deployed in DigitalOcean, deploy your Access Server in DigitalOcean as well so both systems share the same private network.

Refer to the DigitalOcean Access Server Droplet Quick Start Guide.

You can also deploy OpenClaw in a different DigitalOcean VPC and connect it to the Access Server using VPC peering. This allows Access Server to securely route traffic to the OpenClaw server across VPC networks.

Refer to DigitalOcean's Docs.

  1. Sign in to the Access Server Admin Web UI.

  2. Click Access Controls.

    • The Group and User Access Rules tab is displayed.

  3. Click the Global Access Rules tab.

  4. Under IP Addresses and Subnets, select the routing mode NAT.

    • This makes the source IP appear as the Access Server private IP.

  5. Enter the OpenClaw Droplet private IP in the IP Addresses and Subnets field. Example:

    192.0.2.5
  6. Click Save and Restart.

Optional: Configure domain routing

If you configured a domain earlier:

  1. Stay on the Global Access Rules tab.

  2. Under Domains, select NAT.

  3. Enter the domain. Example:

    openclaw.example.com
  4. Click Save and Restart.

Now confirm that OpenClaw can only be accessed through the VPN.

  1. Connect to the Access Server VPN.

  2. Open a web browser.

  3. Navigate to the OpenClaw gateway URL:

    https://<openclaw-private-ip>/?token=<openclaw-token>

    Replace:

    • <openclaw-private-ip> with the private IP.

    • <openclaw-token> with your gateway token.

    Example:

    https://192.0.2.5/?token=ABCDE12345

    If using a domain:

    https://openclaw.example.com/?token=ABCDE12345
  4. The OpenClaw gateway dashboard should display.

  5. Disconnect from the VPN and try to access the public IP address. The connection should fail, confirming that access is restricted to VPN users.