brook icon indicating copy to clipboard operation
brook copied to clipboard

Load balancing with multiple servers (or relays)

Open PRNDA opened this issue 4 years ago • 2 comments

Is it possible to use multiple brook servers (and/or relays) for load balancing?

something like this:

/opt/brook/brook client --server server1:9999 --server server2:9999 --server relay1:9999 --server relay2:9999 --password hello --socks5 127.0.0.1:1080

PRNDA avatar Apr 04 '21 17:04 PRNDA

I achieved this using v2ray and brook. Traffic routes through v2ray first then balances across multiple brook and v2ray servers.

creativebastard avatar May 03 '22 03:05 creativebastard

You could also run a few servers behind CloudFlare/AWS and load balance them. I've just started testing this and so far it works as expected.

creativebastard avatar May 11 '22 08:05 creativebastard

@creativebastard could you please share a v2ray config sample for routing to brook? I'm using brook websocket, not sure how to use v2ray's reverse proxy for this.

difof avatar Nov 01 '22 09:11 difof

{
	"log": {
		"error" : "/var/log/v2ray/error.log",
		"loglevel" : "warning",
		"access" : "/var/log/v2ray/access.log"
	},
	"stats": {},
	"inbounds": [{}],  
	"outbounds": [
		{
	      "protocol": "socks",
	      "settings": {
	        "servers": [
	          {
	            "address": "127.0.0.1",
	            "port": 1080
	          }
	        ]
	      },
	      "tag": "brook-1"
	    },
	    {
	      "protocol": "socks",
	      "settings": {
	        "servers": [
	          {
	            "address": "127.0.0.1",
	            "port": 1081
	          }
	        ]
	      },
	      "tag": "brook-2"
	    },
	{
	  "protocol": "freedom",
	  "settings": {},
	  "tag": "direct"
	},
	{
	  "protocol": "blackhole",
	  "settings": {},
	  "tag": "adblock"
	}
	],
	"routing": {
	  "domainStrategy": "AsIs",
	  "balancers": [
      {
        "tag": "b1",
        "selector": [
                    "brook-1",
                    "brook-2"
         ]
      }
      ],
	  "rules": [
	  	{
	    	"type": "field",
	    	"outboundTag": "brook-1",
	    	"domain": [
					"domain:something.com"
	    	]
	    },
        {
            "type": "field",
            "outboundTag": "direct",
            "domain": [
                    "domain:something",
            ]
        },
	    {
	    	"type": "field",
	    	"outboundTag": "brook-2",
	    	"domain": [
					"domain:another.com"
	    	]
	    },
		{
        	"type": "field",
        	"network": "tcp,udp",
        	"balancerTag": "b1"
      }

	  ]
	}
}

creativebastard avatar Nov 02 '22 08:11 creativebastard

You can do this script brooklinks, checkout https://brook.app

txthinking avatar Jan 14 '24 11:01 txthinking