GUNBOT: The automatic profit generator > Technical Support & Development

Linux Connection Throttler/SSL proxy for Poloniex

(1/2) > >>

dj31:
Disclaimer:

This may work for you, and it may not.   It's not a silver bullet, and you will still get 422's.   No 'optimizations' are performed.  All it does is globally limit the number of simultaneous connections to poloniex.    It currently has the polo IP hard coded, so if it changes -- you gotta change it.  It will redirect all local https requests to poloniex.

Requirements:
- 'nix server
- haproxy installed
- ability to edit hosts file
- port 443 available

Step 1:   Setup haproxy

This is a barebones, no logging, no frills config.

--- Code: ---global
   maxconn 4096
   user haproxy
   group haproxy
   pidfile     /run/haproxy.pid
   daemon

defaults
   mode  http
   option   httplog
   option   dontlognull
   retries  3
   option redispatch
   maxconn  2000
   timeout connect 10000
   timeout server 50000
   timeout client 50000

# Host HA-Proxy web stats on Port 3306 (that will confuse those script kiddies)
listen HAProxy-Statistics
    bind :3306
    mode http
    option httplog
    option httpclose
    stats enable
    stats uri /haproxy?stats
    stats refresh 20s
    stats show-node
    stats show-legends
    stats show-desc Workaround haproxy for SSL
    stats auth admin:nimda

frontend ssl_relay
    bind :443
    mode tcp
    option tcplog
    option socket-stats
    maxconn  5
    default_backend ssl_polo

backend ssl_polo
   mode tcp
   option tcplog
   balance roundrobin
   hash-type consistent
   server x_polo 104.20.12.48:443

--- End code ---

-  Change the stats auth <user>:<password> to your liking.
-  If port 3306 isn't available for stats, change it to whatever you like
-  Set maxconn to however many maximum simultaneous connections you want

You can view stats at:   http://<yourserver>:3306/haproxy?stats

Step 2.  Redirect polo requests

Edit your /etc/hosts file and append the following to the end


--- Code: ---<haproxyIPAddress>   poloniex.com

--- End code ---


I'm sure there are some optimizations/tweaks, but it's a starting point.

AlfonseX:
Cool job ;)
I didn't know haproxy, I will give it a try and dig though its configuration.
How do you find Polo IP?

Keep in touch.

beer-k0in:

--- Quote from: AlfonseX on June 25, 2017, 08:41:12 AM ---How do you find Polo IP?

--- End quote ---

Actually polo uses 2 IPs: 104.20.12.48 and 104.20.13.48. (Bittrex and Kraken using 5).

A tool to get IPs for a domain name is nslookup:


--- Code: ---$ nslookup poloniex.com

Non-authoritative answer:
Name: poloniex.com
Address: 104.20.13.48
Name: poloniex.com
Address: 104.20.12.48

--- End code ---


BK

dj31:
Some slight tweaks.

#1 - use localhost instead of adapter's IP
#2 - use both polo servers on the backend.

New Config

--- Code: ---global
   maxconn 4096
   user haproxy
   group haproxy
   pidfile     /run/haproxy.pid
   daemon

defaults
   mode  http
   option   httplog
   option   dontlognull
   retries  3
   option redispatch
   maxconn  2000
   timeout connect 10000
   timeout server 50000
   timeout client 50000

listen HAProxy-Statistics
    bind :3306
    mode http
    option httplog
    option httpclose
    stats enable
    stats uri /haproxy?stats
    stats refresh 20s
    stats show-node
    stats show-legends
    stats show-desc Workaround haproxy for SSL
    stats auth admin:nimda

frontend ssl_relay
    bind 127.0.0.1:443
    mode tcp
    option tcplog
    option socket-stats
    maxconn  3
    default_backend ssl_polo

backend ssl_polo
   mode tcp
   option tcplog
   balance roundrobin
   hash-type consistent
   server x_polo 104.20.12.48:443
   server x_polo2 104.20.13.48:443

--- End code ---

New /etc/hosts entry

--- Code: ---127.0.0.1       poloniex.com

--- End code ---

Seki92:
error

::::2017/06/25 16:59:10   Error Error: connect ECONNREFUSED 127.0.0.1:443

::::2017/06/25 16:59:11   Error Error: connect ECONNREFUSED 127.0.0.1:443

Navigation

[0] Message Index

[#] Next page

Go to full version