CentOS 7 配置Shadowsocks-libev + simple-obfs

Posted by Sunday on 2017-10-24

源码编译安装

关闭防火墙

1
2
systemctl stop firewalld
systemctl disable firewalld

编译环境准备、解决依赖

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

安装 Libsodium

1
2
3
4
5
6
7
8
export LIBSODIUM_VER=1.0.13
wget https://download.libsodium.org/libsodium/releases/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 源码

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

开始编译 Shadowsocks-libev

1
2
cd ~/shadowsocks-libev
./autogen.sh && ./configure --prefix=/usr/local/shadowsocks-libev && make && make install

Shadowsocks-libev Systemd 配置文件

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
vim /etc/systemd/system/shadowsocks-libev.service
# This file is part of shadowsocks-libev.
#
# Shadowsocks-libev is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This file is default for RPM packaging. See also
# /etc/sysconfig/shadowsocks-libev for environment variables.

[Unit]
Description=Shadowsocks-libev Default Server Service
Documentation=man:shadowsocks-libev(8)
After=network.target

[Service]
Type=simple
#EnvironmentFile=/etc/sysconfig/shadowsocks-libev
User=nobody
Group=nobody
LimitNOFILE=32768
ExecStart=/usr/local/shadowsocks-libev/bin/ss-server -c /etc/shadowsocks-libev/config.json $DAEMON_ARGS
CapabilityBoundingSet=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

Systemd 启动 Shadowsocks-libev

1
2
3
systemctl enable shadowsocks-libev.service
systemctl start shadowsocks-libev.service
systemctl status shadowsocks-libev.service

安装 Simple-obfs

1
2
3
4
5
6
git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
git submodule update --init --recursive
./autogen.sh
./configure && make
make install

配置文件,加入simple-obfs支持

1
2
3
4
5
6
7
8
9
10
11
vim /etc/shadowsocks-libev/config.json
{
"server":"0.0.0.0",
"server_port":8388,
"local_port":1080,
"password":"Password",
"timeout":60,
"method":"chacha20-ietf-poly1305",
"plugin": "obfs-server",
"plugin_opts": "obfs=http"
}

然后重启 Shadowsocks 服务。

1
systemctl restart shadowsocks-libev.service

https://github.com/shadowsocks/shadowsocks-libev