forked from esemeniuc/lowendscript
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeb-3proxy.sh
202 lines (176 loc) · 5.23 KB
/
deb-3proxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
############################################################
# Install 3proxy (version 0.6.1, perfect proxy for LEB, supports authentication, easy config)
############################################################
function install_3proxy {
if [ -z "$1" ]
then
die "Usage: `basename $0` install [http-proxy port #]"
fi
echo "You have chosen port $http_porty"
# Build 3proxy
echo "Downloading and building 3proxy"
mkdir /tmp/proxy
cd /tmp/proxy
wget http://www.3proxy.ru/0.6.1/3proxy-0.6.1.tgz
tar -xvzf 3proxy-0.6.1.tgz
rm 3proxy-0.6.1.tgz
cd 3proxy-0.6.1
apt-get install build-essential
make -f Makefile.Linux
# Navigate to 3proxy Install Directory
cd src
mkdir /etc/3proxy/
# Move 3proxy program to a non-temporary location and navigate there
mv 3proxy /etc/3proxy/
cd /etc/3proxy/
# Create a Log File
touch /var/log/3proxy.log
# Create basic config that sets up HTTP proxy with user authentication
touch /etc/3proxy/3proxy.cfg
cat > "/etc/3proxy/3proxy.cfg" <<END
# Specify valid name servers. You can locate them on your VPS in /etc/resolv.conf
#
nserver 8.8.8.8
nserver 8.8.4.4
# Leave default cache size for DNS requests:
#
nscache 65536
# Leave default timeout as well:
#
timeouts 1 5 30 60 180 1800 15 60
# If your server has several IP-addresses, you need to provide an external one
# Alternatively, you may ignore this line
#external YOURSEVERIP
# Provide the IP-address to be listened
# If you ignore this line, proxy will listen all the server.s IP-addresses
#internal YOURSEVERIP
# Create users proxyuser1 and proxyuser2 and specify a password
#
users \$/etc/3proxy/.proxyauth
# Specify daemon as a start mode
#
daemon
# and the path to logs, and log format. Creation date will be added to a log name
log /var/log/3proxy.log
logformat "- +_L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
# Compress the logs using gzip
#
archiver gz /usr/bin/gzip %F
# store the logs for 30 days
rotate 30
# Configuring http(s) proxy
#
# enable strong authorization. To disable authentication, simply change to 'auth none'
# added authentication caching to make life easier
authcache user 60
auth strong cache
# and restrict access for ports via http(s)-proxy and deny access to local interfaces
#
deny * * 127.0.0.1,192.168.1.1
allow * * * 80-88,8080-8088 HTTP
allow * * * 443,8443 HTTPS
# run http-proxy ... without ntlm-authorization, complete anonymity and port ...
#
proxy -n -p$1 -a
# Configuring socks5-proxy
#
# enable strong authorization and authentication caching
#
# Purge the access-list of http-proxy and allow certain users
#
# set the maximum number of simultaneous connections to 32
#authcache user 60
#auth strong cache
#flush
#allow userdefined
#socks
END
# Give appropriate permissions for config file
chmod 600 /etc/3proxy/3proxy.cfg
# Create external user authentication file
touch /etc/3proxy/.proxyauth
chmod 600 /etc/3proxy/.proxyauth
cat > "/etc/3proxy/.proxyauth" <<END
## addusers in this format:
## user:CL:password
## see for documenation: http://www.3proxy.ru/howtoe.asp#USERS
END
# Create initialization scripty so 3proxy starts with system
touch /etc/init.d/3proxy
chmod +x /etc/init.d/3proxy
cat > "/etc/init.d/3proxy" <<END
#!/bin/sh
#
# chkconfig: 2345 20 80
# description: 3proxy tiny proxy server
#
#
#
#
case "\$1" in
start)
echo Starting 3Proxy
/etc/3proxy/3proxy /etc/3proxy/3proxy.cfg
;;
stop)
echo Stopping 3Proxy
/usr/bin/killall 3proxy
;;
restart|reload)
echo Reloading 3Proxy
/usr/bin/killall -s USR1 3proxy
;;
*)
echo Usage: \$0 "{start|stop|restart}"
exit 1
esac
exit 0
END
# Make sure 3proxy starts with system
update-rc.d 3proxy defaults
# Add Iptable entry for specified port
echo "Adding necessary iptables-entry"
iptables -I INPUT -p tcp --dport $1 -j ACCEPT
if [ -f /etc/iptables.up.rules ];
then
iptables-save < /etc/iptables.up.rules
fi
echo ''
echo '3proxy successfully installed, before you can use it you must add a user and password, for proxy authentication. '
echo 'This can be done using the "3proxyauth [user] [password]" it will add the user to the 3proxy auth file. '
echo 'If you do not want authentication, edit the 3proxy config file /etc/3proxy/3proxy.cfg and set authentication to none (auth none)'
echo 'This will leave your http proxy open to anyone and everyone.'
/etc/init.d/3proxy start
echo "3proxy started"
}
function 3proxyauth {
if [[ -z "$1" || -z "$2" ]]
then
die "Usage: `basename $0` auth username password"
fi
if [ -f /etc/3proxy/.proxyauth ];
then
echo "$1:CL:$2" >> "/etc/3proxy/.proxyauth"
echo "User: $1 successfully added"
else
echo "Please install 3proxy (through this script) first."
fi
}
########################################################################
# START OF PROGRAM
########################################################################
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
case "$1" in
install)
install_3proxy $2
;;
auth)
3proxyauth $2 $3
;;
*)
echo ' '
echo 'Usage:' `basename $0` '[option] [argument]'
echo '- install (Install 3proxy - Free tiny proxy server, with authenticatin support, HTTP, SOCKS5 and whatever you can throw at it)'
echo '- auth (add users/passwords to your proxy user authentication list)'
;;
esac