Geth (go-ethereum)¶
Geth is the Go implementation of Ethereum.
This configuration exposes Geth's RPC and WebSocket interfaces via NGINX.
Start Geth¶
Bash
./geth --cache 4096 \
--rpc --rpcaddr "127.0.0.1" --rpccorsdomain "*" --rpcport "8545" \
--rpcapi "db,eth,net,web3,personal" \
--ws --wsport 8546 --wsaddr "127.0.0.1" --wsorigins "*" \
--wsapi "web3,eth" --maxpeers=100
NGINX Configuration¶
Nginx Configuration File
server {
listen 80;
listen [::]:80;
server_name localhost;
# WebSocket endpoint
location ^~ /ws {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8546/;
}
# RPC endpoint
location ^~ /rpc {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8545/;
}
}