OpenClaw
보안10 분 소요

OpenClaw 원격 액세스를 안전하게 설정하는 방법

SSH 터널, 리버스 프록시, VPN을 사용하여 보안을 유지하면서 OpenClaw 게이트웨이를 원격 액세스용으로 안전하게 노출하는 방법을 알아보세요.

O

OpenClaw Guides

Tutorial Authors

원격 액세스가 필요한 이유

기본적으로 OpenClaw는 127.0.0.1 (localhost만)에 바인딩되어 가장 안전한 구성입니다. 그러나 다음과 같은 경우 원격 액세스가 필요할 수 있습니다:

  • 여행 중에 홈 서버에서 OpenClaw 실행
  • VPS에서 호스팅하고 여러 장치에서 연결
  • 로컬 네트워크에서 AI 어시스턴트 공유

경고: 적절한 인증 및 암호화 없이 OpenClaw를 인터넷에 직접 노출하지 마세요. 이 가이드는 안전한 방법만 다룹니다.

방법 1: SSH 터널 (개인 사용 권장)

SSH 터널링은 개인 원격 액세스를 위한 가장 간단하고 안전한 방법입니다.

원격 서버에서

OpenClaw가 localhost에서 실행 중인지 확인:

bash
openclaw gateway start
# Gateway listening on http://127.0.0.1:18789

로컬 머신에서

SSH 터널 생성:

bash
ssh -L 18789:localhost:18789 user@your-server-ip

이제 로컬 머신에서 http://localhost:18789로 OpenClaw에 액세스할 수 있습니다.

autossh를 사용한 영구 SSH 터널

자동으로 재연결되는 터널:

bash
# autossh 설치
# macOS
brew install autossh

# Ubuntu/Debian
sudo apt install autossh

# 영구 터널 생성
autossh -M 0 -f -N -L 18789:localhost:18789 user@your-server-ip

방법 2: Nginx 리버스 프록시

더 고급 설정의 경우 SSL 종료와 함께 Nginx를 리버스 프록시로 사용합니다.

Nginx 및 Certbot 설치

bash
# Ubuntu/Debian
sudo apt update
sudo apt install nginx certbot python3-certbot-nginx

Nginx 구성

/etc/nginx/sites-available/openclaw 생성:

nginx
server {
    listen 80;
    server_name openclaw.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:18789;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }
}

사이트 활성화:

bash
sudo ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Let's Encrypt로 SSL 추가

bash
sudo certbot --nginx -d openclaw.yourdomain.com

기본 인증 추가

비밀번호 파일 생성:

bash
sudo apt install apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd your-username

Nginx 구성 업데이트:

nginx
server {
    listen 443 ssl;
    server_name openclaw.yourdomain.com;

    # certbot이 추가한 SSL 구성...

    location / {
        auth_basic "OpenClaw Access";
        auth_basic_user_file /etc/nginx/.htpasswd;

        proxy_pass http://127.0.0.1:18789;
        # ... 기타 프록시 설정
    }
}

방법 3: WireGuard VPN

최고의 보안을 위해 VPN을 사용하여 홈 네트워크에 액세스합니다.

WireGuard 설치

bash
# 서버 (Ubuntu/Debian)
sudo apt install wireguard

# 키 생성
wg genkey | tee privatekey | wg pubkey > publickey

서버 구성

/etc/wireguard/wg0.conf 생성:

ini
[Interface]
PrivateKey = <server-private-key>
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = <client-public-key>
AllowedIPs = 10.0.0.2/32

클라이언트 구성

ini
[Interface]
PrivateKey = <client-private-key>
Address = 10.0.0.2/24

[Peer]
PublicKey = <server-public-key>
Endpoint = your-server-ip:51820
AllowedIPs = 10.0.0.1/32
PersistentKeepalive = 25

WireGuard 시작

bash
# 서버
sudo wg-quick up wg0
sudo systemctl enable wg-quick@wg0

# 클라이언트
sudo wg-quick up wg0

이제 VPN IP로 OpenClaw에 액세스: http://10.0.0.1:18789

방법 4: Cloudflare 터널 (Zero Trust)

Cloudflare 터널은 포트를 노출하지 않고 안전한 액세스를 제공합니다.

cloudflared 설치

bash
# macOS
brew install cloudflare/cloudflare/cloudflared

# Linux
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb

인증 및 터널 생성

bash
cloudflared tunnel login
cloudflared tunnel create openclaw

터널 구성

~/.cloudflared/config.yml 생성:

yaml
tunnel: <tunnel-id>
credentials-file: /home/user/.cloudflared/<tunnel-id>.json

ingress:
  - hostname: openclaw.yourdomain.com
    service: http://localhost:18789
  - service: http_status:404

터널 실행

bash
cloudflared tunnel route dns openclaw openclaw.yourdomain.com
cloudflared tunnel run openclaw

보안 모범 사례

1. 속도 제한 활성화

~/.openclaw/openclaw.json에서:

json
{
  "security": {
    "rateLimiting": {
      "enabled": true,
      "maxRequests": 60,
      "windowMs": 60000
    }
  }
}

2. 강력한 API 키 사용

bash
# API 키를 정기적으로 교체
openclaw config set api-key

3. 액세스 로그 모니터링

bash
# 게이트웨이 로그 확인
openclaw logs --follow

4. Fail2Ban 설정 (Nginx용)

bash
sudo apt install fail2ban

# /etc/fail2ban/jail.local 생성
[nginx-http-auth]
enabled = true

비교 표

| 방법 | 보안 | 복잡도 | 최적 용도 | |------|------|--------|-----------| | SSH 터널 | 높음 | 낮음 | 개인 사용 | | Nginx + SSL | 높음 | 중간 | 공개 액세스 | | WireGuard VPN | 매우 높음 | 중간 | 팀 액세스 | | Cloudflare 터널 | 높음 | 낮음 | Zero-trust 설정 |

다음 단계