update documentation
This commit is contained in:
parent
946f2d7a11
commit
89c0e16379
|
@ -2,7 +2,6 @@
|
||||||
config.py
|
config.py
|
||||||
|
|
||||||
dist/
|
dist/
|
||||||
test.go
|
|
||||||
config.yml
|
config.yml
|
||||||
config.yaml
|
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
|
# 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.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
|
25
README.md
25
README.md
|
@ -2,27 +2,26 @@
|
||||||
|
|
||||||
_A round-robin load balancer for HTTP proxies._
|
_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
|
HTTPS proxy servers are not supported.
|
||||||
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.
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
1. `pip install -r requirements.txt`
|
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. Copy `proxy-skeleton/app/config.py.example` to `proxy-skeleton/app/config.py` and fill in your config details.
|
2. `cp config.example.yml config.yml`
|
||||||
3. Deploy the `canihazip` https://git.evulid.cc/cyberes/canihazip and start it.
|
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
|
An example systemd service `loadbalancer.service` is provided.
|
||||||
`loadbalancer.service` is provided as a service example.
|
|
||||||
|
|
||||||
## Special Headers
|
## Special Headers
|
||||||
|
|
||||||
The load balancer accepts special headers to control its behavior.
|
The load balancer accepts special headers to control its behavior.
|
||||||
|
|
||||||
- `Smartproxy-Bypass`: don't use any SmartProxy endpoints.
|
- `Thirdparty-Bypass`: don't use any third-party endpoints for this request.
|
||||||
- `Smartproxy-Disable-BV3HI`: don't filter SmartProxy endpoints by the 503 connect error.
|
- `Thirdparty-Include-Broken`: use all online endpoints for this request, including third-party ones that failed the special test.
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Proxy Load Distributor
|
Description=Proxy Load Balancer
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
SyslogIdentifier=proxy-loadbalancer
|
SyslogIdentifier=proxy-loadbalancer
|
||||||
User=loadbalancer
|
User=loadbalancer
|
||||||
Group=loadbalancer
|
Group=loadbalancer
|
||||||
WorkingDirectory=/srv/loadbalancer/proxy-loadbalancer/proxy-skeleton
|
ExecStart=/srv/loadbalancer/proxy-loadbalancer --config /etc/proxy-loadbalancer/config.yml
|
||||||
ExecStart=/srv/loadbalancer/proxy-loadbalancer/venv/bin/python -m app
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
|
@ -13,6 +13,11 @@ import (
|
||||||
"slices"
|
"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) {
|
func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter, req *http.Request) (string, string, string, string, *url.URL, error) {
|
||||||
if p.BalancerOnline.GetCount() != 0 {
|
if p.BalancerOnline.GetCount() != 0 {
|
||||||
errStr := "balancer is not ready"
|
errStr := "balancer is not ready"
|
||||||
|
@ -29,10 +34,10 @@ func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter,
|
||||||
return "", "", "", "", nil, errors.New(errStr)
|
return "", "", "", "", nil, errors.New(errStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
headerIncludeBrokenThirdparty := req.Header.Get("Thirdparty-Include-Broken")
|
headerIncludeBrokenThirdparty := req.Header.Get(HeaderThirdpartyIncludeBroken)
|
||||||
req.Header.Del("Thirdparty-Include-Broken")
|
req.Header.Del(HeaderThirdpartyIncludeBroken)
|
||||||
headerBypassThirdparty := req.Header.Get("Thirdparty-Bypass")
|
headerBypassThirdparty := req.Header.Get(HeaderThirdpartyBypass)
|
||||||
req.Header.Del("Thirdparty-Bypass")
|
req.Header.Del(HeaderThirdpartyBypass)
|
||||||
if headerBypassThirdparty != "" && headerIncludeBrokenThirdparty != "" {
|
if headerBypassThirdparty != "" && headerIncludeBrokenThirdparty != "" {
|
||||||
errStr := "duplicate options headers detected, rejecting request"
|
errStr := "duplicate options headers detected, rejecting request"
|
||||||
http.Error(w, errStr, http.StatusBadRequest)
|
http.Error(w, errStr, http.StatusBadRequest)
|
||||||
|
|
Loading…
Reference in New Issue