Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ node_modules/
dist/
*.local
.env
.env.*
!.env.example
plans/
.claude/
__pycache__/
*.pyc
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,62 @@ If you already run Express/Node.js, embed the proxy directly instead of running

For production deployment with nginx reverse proxy, see `examples/docker-compose.yml`.

## Alternative Proxy Servers

Don't use Node.js? We provide proxy server examples in **Python**, **Go**, and **PHP**. Each implements the same proxy pattern (token injection, frame sanitization, origin validation).

### Python (aiohttp)

```bash
cd examples/python-proxy
pip install -r requirements.txt
cp .env.example .env # fill in GOCLAW_URL and GOCLAW_TOKEN
python proxy.py
```

Or with Docker:

```bash
cd examples/python-proxy
docker build -t goclaw-proxy-python .
docker run -p 3100:3100 --env-file .env goclaw-proxy-python
```

### Go (gorilla/websocket)

```bash
cd examples/go-proxy
cp .env.example .env # fill in GOCLAW_URL and GOCLAW_TOKEN
go run main.go
```

Or with Docker:

```bash
cd examples/go-proxy
docker build -t goclaw-proxy-go .
docker run -p 3100:3100 --env-file .env goclaw-proxy-go
```

### PHP (Ratchet + ReactPHP)

```bash
cd examples/php-proxy
composer install
cp .env.example .env # fill in GOCLAW_URL and GOCLAW_TOKEN
php proxy.php
```

Or with Docker:

```bash
cd examples/php-proxy
docker build -t goclaw-proxy-php .
docker run -p 3100:3100 --env-file .env goclaw-proxy-php
```

All proxy servers listen on `:3100/ws` by default and support the same environment variables (see [Proxy Server Configuration](#proxy-server-configuration)).

## Configuration

| Option | Type | Default | Description |
Expand Down
20 changes: 20 additions & 0 deletions examples/go-proxy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GoClaw WebChat Proxy — Go
# Copy to .env and fill in the values

# Required: GoClaw Gateway WebSocket URL
GOCLAW_URL=ws://localhost:9090/ws

# Required: Gateway auth token (kept server-side, never exposed to browser)
GOCLAW_TOKEN=your-gateway-token-here

# Optional: Proxy server port (default: 3100)
PORT=3100

# Optional: Allowed origins (comma-separated, empty = allow all)
# ALLOWED_ORIGINS=https://example.com,https://app.example.com

# Optional: Default agent ID (used if client doesn't specify one)
# DEFAULT_AGENT_ID=your-agent-id

# Optional: API key to authenticate proxy connections (empty = no auth)
# PROXY_API_KEY=your-secret-api-key
13 changes: 13 additions & 0 deletions examples/go-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY main.go .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o proxy .

FROM alpine:3.19
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY --from=builder /app/proxy .
EXPOSE 3100
CMD ["./proxy"]
8 changes: 8 additions & 0 deletions examples/go-proxy/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module goclaw-proxy

go 1.22

require (
github.com/gorilla/websocket v1.5.3
github.com/joho/godotenv v1.5.1
)
4 changes: 4 additions & 0 deletions examples/go-proxy/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
Loading
Loading