Last active
August 16, 2024 16:24
-
-
Save freshwind2004/c827e742285cdb9542403ff021486bb0 to your computer and use it in GitHub Desktop.
Chisel + Shadowsocks + Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#DomianSettings | |
#Turn on Cloudflare CDN orange icon and check if you can visit your blocked IP | |
domain.com 111.222.333.444 | |
#Server-Side | |
#Setup Shadowsocks with port 10086 & rc-md5 (Debian) | |
wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev-debian.sh | |
chmod +x shadowsocks-libev-debian.sh | |
./shadowsocks-libev-debian.sh 2>&1 | tee shadowsocks-libev-debian.log | |
#Download chisel | |
wget https://github.com/jpillora/chisel/releases/download/1.3.1/chisel_linux_386.gz | |
gzip -d chisel_linux_386.gz | |
chmod +x chisel_linux_386 | |
#Autostart chisel | |
nano /etc/rc.local | |
#Add following line (redirect normal http to baidu) | |
nohup /root/chisel_linux_386 server --auth user:pass --socks5 --port 2052 --proxy https://baidu.com >/dev/null 2>&1 & | |
#Client-Side | |
#Run chisel on client | |
./chisel_darwin_amd64 client --auth user:pass --keepalive 60s domain.com:2052 10086 | |
#Or | |
nohup ~/chisel_darwin_amd64 client --auth user:pass --keepalive 60s domain.com:2052 10086 >/dev/null 2>&1 & | |
#We use port 2052 to get Cloudflare's CDN proxy | |
#HTTP ports supported by Cloudflare: | |
80 | |
8080 | |
8880 | |
2052 | |
2082 | |
2086 | |
2095 | |
#HTTPS ports supported by Cloudflare: | |
443 | |
2053 | |
2083 | |
2087 | |
2096 | |
8443 | |
#Start and test your service: | |
service $YOUR_SERVICE_NAME start | |
service $YOUR_SERVICE_NAME stop | |
#Install service to be run at boot-time: | |
update-rc.d $YOUR_SERVICE_NAME defaults | |
#Init.d Script | |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: chisel | |
# Required-Start: $local_fs $network $named $time $syslog | |
# Required-Stop: $local_fs $network $named $time $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: chisel | |
### END INIT INFO | |
SCRIPT="/root/chisel_linux_386 server --auth freshwind:password --socks5 --port 2052 --proxy https://nosame.net" | |
RUNAS=root | |
PIDFILE=/var/run/chisel.pid | |
LOGFILE=/var/log/chisel.log | |
start() { | |
if [ -f $PIDFILE ] && [ -s $PIDFILE ]; then | |
echo 'Service already running' >&2 | |
return 1 | |
fi | |
echo 'Starting service…' >&2 | |
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!" | |
su -c "$CMD" $RUNAS > "$PIDFILE" | |
# Try with this command line instead of above if not workable | |
# su -s /bin/sh $RUNAS -c "$CMD" > "$PIDFILE" | |
sleep 2 | |
PID=$(cat $PIDFILE) | |
if pgrep -u $RUNAS -f $NAME > /dev/null | |
then | |
echo "$NAME is now running, the PID is $PID" | |
else | |
echo '' | |
echo "Error! Could not start $NAME!" | |
fi | |
} | |
stop() { | |
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then | |
echo 'Service not running' >&2 | |
return 1 | |
fi | |
echo 'Stopping service…' >&2 | |
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE" | |
echo 'Service stopped' >&2 | |
} | |
status() { | |
printf "%-50s" "Checking chisel..." | |
if [ -f $PIDFILE ] && [ -s $PIDFILE ]; then | |
PID=$(cat $PIDFILE) | |
if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then | |
printf "%s\n" "The process appears to be dead but pidfile still exists" | |
else | |
echo "Running, the PID is $PID" | |
fi | |
else | |
printf "%s\n" "Service not running" | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment