安装Shadowsocks-libev

添加更新源。
echo "deb http://http.us.debian.org/debian jessie main" >> /etc/apt/sources.list
apt-get update

安装依赖。
apt-get -y --no-install-recommends install gettext build-essential autoconf automake libtool openssl libssl-dev zlib1g-dev xmlto asciidoc libpcre3-dev libudns-dev libev-dev git ca-certificates unzip libc-ares2

安装libsodium。

cd
wget --no-check-certificate https://github.com/jedisct1/libsodium/releases/download/1.0.12/libsodium-1.0.12.tar.gz
tar xf libsodium-1.0.12.tar.gz && cd libsodium-1.0.12
./configure && make && make install
ldconfig

安装c-ares。

cd
git clone https://github.com/c-ares/c-ares.git
cd c-ares
./buildconf
./configure && make && make install

安装shadowsocks-libev。

cd
wget https://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.1.3/shadowsocks-libev-3.1.3.tar.gz
tar zxf shadowsocks-libev-3.1.3.tar.gz &&cd shadowsocks-libev-3.1.3
./configure
make && make install

安装Simple-obfs

可以伪装网站流量,和网站共用443端口也需要它。

git clone https://github.com/shadowsocks/simple-obfs
cd simple-obfs && git submodule init && git submodule update
./autogen.sh
./configure --prefix=/usr --disable-documentation
make && make install

配置

新建配置文件/etc/shadowsocks-libev/config.json

{
    "server":["[::0]", "0.0.0.0"],
    "server_port":443,
    "local_port":1080,
    "password":"yourpassword",
    "timeout":60,
    "method":"rc4-md5",
    "dns_ipv6":true,
    "plugin":"obfs-server",
    "plugin_opts":"obfs=http;failover=127.0.0.1:8443"
}

其中server指定了ipv6地址和v4地址,dns_ipv6优先使用ipv6解析地址,最后两行设置使用obfs伪装http流量并将网站请求转到8443端口。

需要修改nginx配置,将443端口改为8443。

开机自启

(尝试了源码中的'shadowsocks-libev.init'和'shadowsocks-libev.default'创建服务,启动没有反应。)

新建/etc/init.d/ss-libev.sh

#!/bin/sh
### BEGIN INIT INFO
# Provides:          shadowsocks-libev
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description: ss-server
# Description: shadowsocks-libev
### END INIT INFO
/usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json -f /tmp/ss-server.pid

chmod +x /etc/init.d/ss-libev.sh添加执行权限。

update-rc.d ss-libev.sh defaults添加启动脚本

加速

之前用过这两个方法,不过在请求多的时候内存占用会很高,有时候反而变慢(定时重启会缓解),所以关掉了。
(需要系统支持,可能不适用与debian 7 x86)
Kcptun:https://ihkk.net/bandwagon-host-improve/ (损人不利己,慎用)
BBR:我的印象笔记链接(原文404)

参考:
http://awy.me/2017/05/64m-nei-cun-vps-li-yong-shou-zha-yi-an-zhuang-shadowsocks-libev/
https://www.denpe.com/debian-autorun/
https://bbs.letitfly.me/d/301