Repository navigation
v0.1.0
JSON-RPC HTTP Proxy v0.1.0
A simple, configurable HTTP proxy for JSON-RPC requests written in Go. The proxy routes requests to different backend services based on the JSON-RPC method name.
Features
- Route JSON-RPC requests to different backends based on method name
- Intelligent routing of batch requests to appropriate backends
- YAML-based configuration
- Fallback to default URL for undefined methods
- Transparent proxy that preserves headers and status codes
Installation
Using Docker (Recommended)
# Pull the latest image
docker pull ghcr.io/omegatymbjiep/jsonrpc-proxy:latest
# Run the container
docker run -p 8080:8080 -v $(pwd)/config.yaml:/app/config/config.yaml ghcr.io/omegatymbjiep/jsonrpc-proxy:latestUsing Docker Compose
# Start the service
docker-compose up -dBuilding from Source
git clone https://github.com/omegatymbjiep/jsonrpc-proxy.git
cd jsonrpc-proxy
go build -o jsonrpc-proxy
./jsonrpc-proxy -config=config.yaml -port=8080Configuration
Create a config.yaml file with your routing rules:
# Default destination URL for any methods not explicitly defined
default_url: "https://mainnet.infura.io/v3/your-project-id"
# Method-specific routing
routes:
- method: "eth_chainId"
url: "https://polygon-rpc.com"
- method: "eth_blockNumber"
url: "https://rpc.ankr.com/eth"Example Usage
# Single request
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \
http://localhost:8080
# Batch request
curl -X POST -H "Content-Type: application/json" \
--data '[
{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1},
{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}
]' \
http://localhost:8080Known Limitations
- Currently, the proxy does not support authentication for backend services
- No caching mechanism for responses
- No rate limiting