CentOS7编译安装shadowsocks-libev + simple-obfs混淆

安装前推荐系统先完成BBR的配置,配置方法可参考《如何在CentOS7上启用BBR提速》

安装shadowsocks-libev

获取shadowsocks-libev源码

1
2
3
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init --recursive

安装基本构建依赖

1
yum install gettext gcc autoconf libtool automake make asciidoc xmlto c-ares-devel libev-devel pcre-devel

安装libsodium

1
2
3
4
5
6
7
8
9
export LIBSODIUM_VER=1.0.16
wget https://download.libsodium.org/libsodium/releases/old/libsodium-$LIBSODIUM_VER.tar.gz
tar xvf libsodium-$LIBSODIUM_VER.tar.gz
pushd libsodium-$LIBSODIUM_VER
./configure --prefix=/usr && make
sudo make install
popd
sudo ldconfig

安装MbedTLS

1
2
3
4
5
6
7
8
export MBEDTLS_VER=2.6.0
wget https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz
tar xvf mbedtls-$MBEDTLS_VER-gpl.tgz
pushd mbedtls-$MBEDTLS_VER
make SHARED=1 CFLAGS=-fPIC
sudo make DESTDIR=/usr install
popd
sudo ldconfig

安装shadowsocks-libev

按照Shadowsocks-libev的README,在make时失败,解决方法https://github.com/shadowsocks/shadowsocks-libev/issues/1164#issuecomment-319578410
安装过程如下:

1
2
3
./autogen.sh
./configure --with-sodium-include=/usr/include --with-sodium-lib=/usr/local/lib --with-mbedtls-include=/usr/include --with-mbedtls-lib=/usr/lib
make && make install

安装simple-obfs

获取simple-obfs源码

1
2
3
git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
git submodule update --init --recursive

安装simple-obfs

1
2
3
./autogen.sh
./configure
make && make install

配置shadowsocks-libev服务

创建shadowsocks配置文件

1
2
mkdir -p /etc/shadowsocks/
touch /etc/shadowsocks/config.json

修改配置文件内容如下:

1
2
3
4
5
6
7
8
9
10
11
{
"server":"0.0.0.0",
"server_port":8388,
"local_port":1080,
"password":"password",
"timeout":60,
"method":"chacha20-ietf-poly1305",
"user":"daemon",
"plugin":"obfs-server",
"plugin_opts":"obfs=http;failover=example.com"
}

注意:需要修改password的内容。

创建shadowsocks启动脚本

1
2
touch /etc/init.d/shadowsocks
chmod +x /etc/init.d/shadowsocks

修改脚本内容如下:

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
#!/usr/bin/env bash
# chkconfig: 2345 90 10
# description: A secure socks5 proxy, designed to protect your Internet traffic.

### BEGIN INIT INFO
# Provides: Shadowsocks-libev
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks-libev server
### END INIT INFO

# Author: Teddysun <[email protected]>
if [ -f /usr/local/bin/ss-server ]; then
DAEMON=/usr/local/bin/ss-server
elif [ -f /usr/bin/ss-server ]; then
DAEMON=/usr/bin/ss-server
fi
NAME=Shadowsocks-libev
CONF=/etc/shadowsocks/config.json
PID_DIR=/var/run
PID_FILE=$PID_DIR/shadowsocks.pid
RET_VAL=0

[ -x $DAEMON ] || exit 0

if [ ! -d $PID_DIR ]; then
mkdir -p $PID_DIR
if [ $? -ne 0 ]; then
echo "Creating PID directory $PID_DIR failed"
exit 1
fi
fi

if [ ! -f $CONF ]; then
echo "$NAME config file $CONF not found"
exit 1
fi

check_running() {
if [ -r $PID_FILE ]; then
read PID < $PID_FILE
if [ -d "/proc/$PID" ]; then
return 0
else
rm -f $PID_FILE
return 1
fi
else
return 2
fi
}

do_status() {
check_running
case $? in
0)
echo "$NAME (pid $PID) is running..."
;;
1|2)
echo "$NAME is stopped"
RET_VAL=1
;;
esac
}

do_start() {
if check_running; then
echo "$NAME (pid $PID) is already running..."
return 0
fi
$DAEMON -uv -c $CONF -f $PID_FILE
if check_running; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
RET_VAL=1
fi
}

do_stop() {
if check_running; then
kill -9 $PID
rm -f $PID_FILE
echo "Stopping $NAME success"
else
echo "$NAME is stopped"
RET_VAL=1
fi
}

do_restart() {
do_stop
do_start
}

case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RET_VAL=1
;;
esac

exit $RET_VAL

配置shadowsocks开机启动

1
chkconfig --add shadowsocks

启动shadowsocks

1
/etc/init.d/shadowsocks start

CentOS7编译安装shadowsocks-libev + simple-obfs混淆

https://www.junle.org/CentOS7编译安装shadowsocks-libev-simple-obfs混淆/

作者

Junle

发布于

2017-06-30

更新于

2024-03-22

许可协议

评论