Created
July 22, 2020 01:16
-
-
Save Someguy123/15fc811f5aba2ece66911d39eab53308 to your computer and use it in GitHub Desktop.
Hive RPC Nginx Config with health endpoint's for Hivemind, Full / Fat Node + Acc Hist - Used by Privex Inc. for direct.hived.privex.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################### | |
# | |
# Hive RPC Nginx Config with health endpoint's for Hivemind, Full / Fat Node + Acc Hist | |
# | |
# (C) 2020 Privex Inc. + Someguy123 | |
# https://www.privex.io https://peakd.com/@someguy123 | |
# | |
####################### | |
# Dirty Hack. Causes nginx to retry jussi | |
upstream hivesrvs { | |
server 127.0.0.1:8085; | |
server 127.0.0.1:8085; | |
server 127.0.0.1:8085; | |
server 127.0.0.1:8085; | |
keepalive 30; | |
} | |
# Dirty Hack. Causes nginx to retry websockets | |
upstream hivews { | |
server 127.0.0.1:8290; | |
server 127.0.0.1:8290; | |
server 127.0.0.1:8290; | |
server 127.0.0.1:8290; | |
keepalive 30; | |
} | |
# LOW MEMORY / ACCOUNT HISTORY node HTTP API. For privex's RPC node, that's on localhost at 8291 | |
upstream hivelowmem { | |
server 127.0.0.1:8291; | |
keepalive 8; | |
} | |
# FULL MEMORY / FAT node HTTP API. For privex's RPC node, that's on localhost at 8291 | |
upstream hivefullmem { | |
server 127.0.0.1:8293; | |
keepalive 8; | |
} | |
server { | |
server_name direct.hived.privex.io de1.hived.privex.io hived.privex.io; | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
listen 443 http2 ssl default_server; | |
listen [::]:443 http2 ssl default_server; | |
# Route /health/hivemind along with /health/hivemind/* to Hivemind's /health | |
# endpoint - assuming Hivemind is running at 127.0.0.1:8000 | |
location ~ ^/health/hivemind { | |
rewrite ^/(.*)? /health break; | |
proxy_pass http://127.0.0.1:8000; | |
proxy_http_version 1.1; | |
} | |
# FULL / FAT node health endpoint | |
location ~ ^/health/(full|fat) { | |
rewrite /(.*) / break; | |
proxy_method POST; | |
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_body '{"jsonrpc":"2.0","method":"condenser_api.get_dynamic_global_properties","params":[]}'; | |
proxy_set_header Content-Type application/json; | |
# Call get_dynamic_global_properties on the FULL / FAT node's HTTP port | |
proxy_pass http://hivefullmem; | |
} | |
# LOW MEM / ACC HIST node health endpoint | |
location ~ ^/health/(low|lite|hist|acchist|accounthist) { | |
rewrite /(.*) / break; | |
proxy_method POST; | |
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_body '{"jsonrpc":"2.0","method":"condenser_api.get_dynamic_global_properties","params":[]}'; | |
proxy_set_header Content-Type application/json; | |
# Call get_dynamic_global_properties on the LOW MEMORY / ACCOUNT HISTORY node's HTTP port | |
proxy_pass http://hivelowmem; | |
} | |
# Handles both HTTP JSON-RPC requests AND websocket connections | |
# When "Upgrade: websocket" is detected, proxy_pass is changed to the websocket upstream | |
location ~ ^(/|/ws) { | |
if ($http_upgrade = "websocket") { | |
proxy_pass http://hivews; | |
} | |
proxy_pass http://hivesrvs; | |
proxy_set_header Connection ""; | |
include snippets/rpc.conf; | |
} | |
} | |
####################### | |
# | |
# Hive RPC Nginx Config with health endpoint's for Hivemind, Full / Fat Node + Acc Hist | |
# | |
# (C) 2020 Privex Inc. + Someguy123 | |
# https://www.privex.io https://peakd.com/@someguy123 | |
# | |
####################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################### | |
# | |
# Hive RPC Nginx Config with health endpoint's for Hivemind, Full / Fat Node + Acc Hist | |
# | |
# (C) 2020 Privex Inc. + Someguy123 | |
# https://www.privex.io https://peakd.com/@someguy123 | |
# | |
####################### | |
limit_req zone=ws burst=30; | |
# RPC access log is super spammy. Only enable temporarily if needed. | |
#access_log /var/log/nginx/rpc_access.log upstreamlog; | |
access_log off; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
proxy_connect_timeout 1h; | |
proxy_send_timeout 1h; | |
proxy_read_timeout 1h; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
keepalive_timeout 65; | |
keepalive_requests 100000; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
proxy_ssl_verify off; | |
####################### | |
# | |
# Hive RPC Nginx Config with health endpoint's for Hivemind, Full / Fat Node + Acc Hist | |
# | |
# (C) 2020 Privex Inc. + Someguy123 | |
# https://www.privex.io https://peakd.com/@someguy123 | |
# | |
####################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment