update documentation

This commit is contained in:
Cyberes 2024-04-12 18:34:47 -06:00
parent 946f2d7a11
commit 89c0e16379
4 changed files with 23 additions and 22 deletions

2
.gitignore vendored
View File

@ -2,7 +2,6 @@
config.py
dist/
test.go
config.yml
config.yaml
@ -167,4 +166,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

View File

@ -2,27 +2,26 @@
_A round-robin load balancer for HTTP proxies._
does not support downstream https servers.
This is a simple proxy load balancer that will route requests to a cluster of proxy backends in a round-robin fashion.
This makes it easy to connect your clients to a large number of proxy servers without worrying about implementing
anything special clientside.
This is a simple load balancer using [proxy.py](https://github.com/abhinavsingh/proxy.py) that will route requests to a
cluster of proxy backends in a round-robin fashion. This makes it easy to connect your clients to a large number of
proxy
servers without worrying about implementing anything special clientside.
HTTPS proxy servers are not supported.
## Install
1. `pip install -r requirements.txt`
2. Copy `proxy-skeleton/app/config.py.example` to `proxy-skeleton/app/config.py` and fill in your config details.
3. Deploy the `canihazip` https://git.evulid.cc/cyberes/canihazip and start it.
1. Download the latest release from [/releases](https://git.evulid.cc/cyberes/proxy-loadbalancer/releases) or run `./build.sh` to build the program locally.
2. `cp config.example.yml config.yml`
3. Edit the config.
4. Start the loadbalancer with `./proxy-loadbalancer --config [path to your config.yml]`
## Use
You can run your own "public IP delivery server" `canihazip` <https://git.evulid.cc/cyberes/canihazip> or use the default `api.ipify.org`
To start the load balancer server, navigate to `./proxy-skeleton` and run `python3 -m app`. The systemd service
`loadbalancer.service` is provided as a service example.
An example systemd service `loadbalancer.service` is provided.
## Special Headers
The load balancer accepts special headers to control its behavior.
- `Smartproxy-Bypass`: don't use any SmartProxy endpoints.
- `Smartproxy-Disable-BV3HI`: don't filter SmartProxy endpoints by the 503 connect error.
- `Thirdparty-Bypass`: don't use any third-party endpoints for this request.
- `Thirdparty-Include-Broken`: use all online endpoints for this request, including third-party ones that failed the special test.

View File

@ -1,13 +1,12 @@
[Unit]
Description=Proxy Load Distributor
Description=Proxy Load Balancer
After=network.target
[Service]
SyslogIdentifier=proxy-loadbalancer
User=loadbalancer
Group=loadbalancer
WorkingDirectory=/srv/loadbalancer/proxy-loadbalancer/proxy-skeleton
ExecStart=/srv/loadbalancer/proxy-loadbalancer/venv/bin/python -m app
ExecStart=/srv/loadbalancer/proxy-loadbalancer --config /etc/proxy-loadbalancer/config.yml
Restart=always
[Install]

View File

@ -13,6 +13,11 @@ import (
"slices"
)
var (
HeaderThirdpartyIncludeBroken = "Thirdparty-Include-Broken"
HeaderThirdpartyBypass = "Thirdparty-Bypass"
)
func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter, req *http.Request) (string, string, string, string, *url.URL, error) {
if p.BalancerOnline.GetCount() != 0 {
errStr := "balancer is not ready"
@ -29,10 +34,10 @@ func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter,
return "", "", "", "", nil, errors.New(errStr)
}
headerIncludeBrokenThirdparty := req.Header.Get("Thirdparty-Include-Broken")
req.Header.Del("Thirdparty-Include-Broken")
headerBypassThirdparty := req.Header.Get("Thirdparty-Bypass")
req.Header.Del("Thirdparty-Bypass")
headerIncludeBrokenThirdparty := req.Header.Get(HeaderThirdpartyIncludeBroken)
req.Header.Del(HeaderThirdpartyIncludeBroken)
headerBypassThirdparty := req.Header.Get(HeaderThirdpartyBypass)
req.Header.Del(HeaderThirdpartyBypass)
if headerBypassThirdparty != "" && headerIncludeBrokenThirdparty != "" {
errStr := "duplicate options headers detected, rejecting request"
http.Error(w, errStr, http.StatusBadRequest)