Skip to content

Instantly share code, notes, and snippets.

@Laxman-SM
Last active July 15, 2022 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laxman-SM/1a7eefabae0fea5bb68c46e975fc0c43 to your computer and use it in GitHub Desktop.
Save Laxman-SM/1a7eefabae0fea5bb68c46e975fc0c43 to your computer and use it in GitHub Desktop.
nginx.conf reverse proxy
user www-data;
worker_processes auto;
pid /run/nginx.pid;
worker_rlimit_nofile 65535;
events { worker_connections 10000; }
http {
map $http_upgrade $connection_upgrade {
default upgrade;
‘’ close;
}
upstream polygon {
server 127.0.0.1:26657;
}
upstream syn-polygon {
server 127.0.0.1:8545/$2; max_conns=1000;
}
upstream syn-polygon-ws {
server localhost:8546/$2; max_conns=1000;
}
server {
listen 80;
}
location ^~ /ws/ {
proxy_pass http://syn-polygon;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
rewrite ^/(ws)/(.*)$ /$2 break;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /rpc/ {
proxy_pass http://syn-polygon-ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
rewrite ^/(ws)/(.*)$ /$2 break;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://polygon;
try_files $uri /index.html;
proxy_set_header Host $http_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;
}
}
}
#sudo systemctl restart nginx.service && tail -f /var/log/nginx/access.log
#curl -vv http://localhost/ws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment