Add new nginx-based corsproxy for btc rpc

This commit is contained in:
Taylor Helsper 2023-08-26 00:13:18 -05:00
parent 1e97790000
commit eee8f7f184
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,42 @@
upstream bitcoind {
# local server
server 127.0.0.1:8332;
# remote server
#server 192.168.0.22:8332
}
## mainnet configuration
server {
listen 8336;
server_name bitcoind.localhost;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'POST, OPTIONS';
# Custom headers and headers various browsers *should* be OK with but aren't
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# Tell client that this pre-flight info is valid for 20 days
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'POST, OPTIONS';
# Custom headers and headers various browsers *should* be OK with but aren't
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
proxy_pass http://bitcoind;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For "$http_x_forwarded_for, $realip_remote_addr";
}
}

View File

@ -33,7 +33,8 @@ ufw allow from 172.17.0.0/16 to any port 28333 comment 'allow Dojo zmqrawtx'
ufw allow from 172.28.0.0/16 to any port 28333 comment 'allow Dojo zmqrawtx'
ufw allow from 172.17.0.0/16 to any port 28334 comment 'allow Dojo zmqhashblock'
ufw allow from 172.28.0.0/16 to any port 28334 comment 'allow Dojo zmqhashblock'
ufw allow 8335 comment 'allow corsproxy for btc rpc'
ufw allow 8335 comment 'allow corsproxy for btc rpc (old)'
ufw allow 8336 comment 'allow nginx proxy for btc rpc 2'
ufw allow 8443 comment 'allow Lightning Terminal'
ufw allow 2222 comment 'allow WebSSH2'
ufw allow 2223 comment 'allow WebSSH2 HTTPS'
@ -44,6 +45,7 @@ ufw allow 3003 comment 'allow BTC RPC Explorer HTTPS'
ufw allow 3010 comment 'allow RTL'
ufw allow 3011 comment 'allow RTL HTTPS'
ufw allow 3020 comment 'allow Caravan'
ufw allow 3021 comment 'allow Caravan HTTPS'
ufw allow 3030 comment 'allow Thunderhub'
ufw allow 3031 comment 'allow Thunderhub HTTPS'
ufw allow 3493 comment 'allow Network UPS Tools'