Skip to content

Commit 72bc1bf

Browse files
committed
Initial commit
0 parents  commit 72bc1bf

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM alpine
2+
RUN apk add --no-cache \
3+
curl \
4+
bash \
5+
git \
6+
dumb-init \
7+
openssl
8+
9+
WORKDIR /app
10+
ADD glider glider.conf entrypoint.sh ./
11+
12+
EXPOSE 15000
13+
14+
ENTRYPOINT ["/app/entrypoint.sh"]
15+
CMD ["/app/glider", "-config", "/app/glider.conf"]

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Simple Proxy Rotator
2+
3+
`Simple Proxy Rotator` - acts as an http(s) forward proxy rotator.
4+
5+
It uses [glider](https://github.com/nadoo/glider) to evenly requests to a list of configured proxies.
6+
7+
## Introduction
8+
9+
You have: a list of http(s) proxies bought from a provider
10+
11+
You need: to distribute http(s) requests amongst those proxies.
12+
13+
Solution: configure your clients to use `Simple Proxy Rotator` as the forward proxy, and it will distribute the requests in round robin mode amongst its configured proxies.
14+
15+
Additionally, `Simple Proxy Rotator` will check each proxy every 60 seconds and remove it from the pool in case of error.
16+
17+
## Setup
18+
19+
The forward proxy rotator is exposed on port `15000`.
20+
21+
The proxy list can be configured in two ways :
22+
23+
- Using an environment variable : `PROXY_LIST_URL`. The proxy list will be downloaded from the given URL.
24+
- By mounting the list as a volume on `/app/proxy-list.txt`
25+
26+
The proxy list should have 1 proxy per line using the following format : `http://[username]:[password]@[host]:[port]`. Example
27+
28+
````
29+
http://user1:password1@12.34.56.78:1111
30+
http://user2:password2@98.76.54.32:2222
31+
...
32+
````
33+
34+
## Usage
35+
36+
### Start the container using a downloadable proxy list
37+
38+
````
39+
docker run -p 1234:15000 -e PROXY_LIST_URL=https://gist.githubusercontent.com/you/private-gist-hash/raw/proxy-list.txt almathie/simple-proxy-rotator
40+
````
41+
42+
### Start the container using a volume mounted proxy list
43+
44+
````
45+
docker run -p 1234:15000 -v /path/to/proxy-list.txt:/app/proxy-list.txt almathie/simple-proxy-rotator
46+
````
47+
48+
### Use the rotator
49+
50+
````
51+
curl -x "http://127.0.0.1:1234" "https://google.com"
52+
````

entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [[ -z "${PROXY_LIST_URL}" ]]; then
5+
echo "Using mounted proxy list"
6+
touch /app/proxy-list.txt
7+
echo " ---> Done"
8+
else
9+
echo "Downloading proxy list from $PROXY_LIST_URL"
10+
curl -s $PROXY_LIST_URL > /app/proxy-list.txt
11+
echo " ---> Done"
12+
fi
13+
14+
echo "Adding proy list to config file"
15+
# Remove blank lines
16+
sed -i '/^$/d' /app/proxy-list.txt
17+
# Prepend forward= in front of each line to match glider config syntax
18+
sed -i 's/^/forward=/' /app/proxy-list.txt
19+
# Randomize and happen
20+
cat /app/proxy-list.txt | shuf >> /app/glider.conf
21+
echo " ---> Done"
22+
23+
echo "Using config file"
24+
cat /app/glider.conf
25+
26+
echo ""
27+
echo "Starting process"
28+
exec "$@"

glider

5.96 MB
Binary file not shown.

glider.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
verbose=True
2+
3+
listen=:15000
4+
5+
# Round Robin
6+
strategy=rr
7+
8+
# This website is not chosen randomly.
9+
# To perform the check, glider sends a CONNECT request
10+
# To the configured domain and port of checkwebsite
11+
# Then send an HTTP GET request on / without negociating TLS
12+
# It expects a response from that request but does not check the
13+
# status.
14+
#
15+
# Some proxies refuse CONNECT requests for target
16+
# whose port is other that 443. So we need checkwebsite to
17+
# finish in :443
18+
# And most websites will simply close the TCP channel without
19+
# responding if you send an HTTP request without TLS on port
20+
# 443. Which thus fails the check while the proxy itself is fine.
21+
# Few domains will reply with a 400 error which is good enough
22+
# for this check.
23+
# Some known domains that do that are :
24+
# httpbin.org // tomorrowland.com // amazon.com // cloudflare.com
25+
# Just choose the most reliable one
26+
checkwebsite=cloudflare.com:443
27+
checkinterval=60
28+

0 commit comments

Comments
 (0)