Shadowsocks搭建


1. Vultr VPS

  • 支持Paypal Alipay等支付方式(最低充值**$5**)

  • 选择合适的数据中心,目前,Vultr VPS拥有日本、美国、德国、法国、荷兰等地,一共14个数据中心可以选择。

  • 通过Vultr VPS Ping主机14个数据中心时延对比进行适当选择:

Tip:个人建议,如果是中国访问,选择东京、洛杉矶,速度是比较快的。

  • 由于东京和洛杉矶的**$2.5/mo的VPS都out of stock,测试需要选择New York(NJ)**。

2. Deploy New Server

  • 如下图步骤进行创建,最后选择Deploy Now。

  • 此时需要等一段时间安装系统,状态如下:

  • 系统安装成功后,状态如下:

  • 选择Manage后可以看到Server的具体信息状态:

3. Shadowsocks Install

  • 使用SSH登录VPS

  • Shadowsocks一键自动安装脚本

    Auto Install Shadowsocks(Python) Server for CentOS/Debian/Ubuntu

    使用root用户登录,运行以下命令

Shadowsocks(SS)

wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
chmod +x shadowsocks.sh
./shadowsocks.sh 2>&1 | tee shadowsocks.log

ShadowsocksR(SSR)

wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
chmod +x shadowsocks-all.sh
./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log

Tips:安装期间需要设置服务器密码、端口、加密方式

  • 安装完成后,脚本提示如下:

Shadowsocks(SS)

Congratulations, Shadowsocks-python server install completed!
Your Server IP        :  `your_server_ip`
Your Server Port      :  `your_server_port`
Your Password         :  `your_password`
Your Encryption Method:  `your_encryption_method`

Welcome to visit:https://teddysun.com/342.html
Enjoy it!

ShadowsocksR(SSR)

Starting ShadowsocksR success

Congratulations, ShadowsocksR server install completed!
Your Server IP        :  97.64.108.226
Your Server Port      :  52821
Your Password         :  ans#150
Your Protocol         :  origin
Your obfs             :  http_simple_compatible
Your Encryption Method:  chacha20-ietf

Your QR Code: (For ShadowsocksR Windows, Android clients only)
 ssr://OTcuNjQuMTA4LjIyNjo1MjgyMTpvcmlnaW46Y2hhY2hhMjAtaWV0ZjpodHRwX3NpbXBsZV9jb21wYXRpYmxlOllXNXpJekUxTUEvP29iZnNwYXJhbT0=
Your QR Code has been saved as a PNG file path:
 /root/shadowsocks_r_qr.png

Welcome to visit: https://teddysun.com/486.html
Enjoy it!
  • 卸载方法:

    使用root用户登录,运行以下命令:

./shadowsocks.sh uninstall

4. Shadowsocks configuration

  • 配置文件路径:/etc/shadowsocks.json

  • 单用户配置文件示例

cat /etc/shadowsocks.json
{
    "server":"0.0.0.0",
    "server_port":your_server_port,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"your_password",
    "timeout":300,
    "method":"your_encryption_method",
    "fast_open":false
}
  • 多用户配置文件示例

cat /etc/shadowsocks.json
{
    "server":"0.0.0.0",
    "server_port":your_server_port,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "port_password":{
         "8989":"password0",
         "9001":"password1",
         "9002":"password2",
         "9003":"password3",
         "9004":"password4"
    },
    "timeout":300,
    "method":"your_encryption_method",
    "fast_open": false
}
  • 使用命令

启动:/etc/init.d/shadowsocks start
停止:/etc/init.d/shadowsocks stop
重启:/etc/init.d/shadowsocks restart
状态:/etc/init.d/shadowsocks status
  • 正常运行状态

service Shadowsocks status
Redirecting to /bin/systemctl status Shadowsocks.service
 shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
   Loaded: loaded (/etc/rc.d/init.d/shadowsocks; bad; vendor preset: disabled)
   Active: active (running) since Fri 2017-10-20 01:55:28 CST; 9h ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/shadowsocks.service
           └─1036 /bin/python /usr/bin/ssserver -c /etc/shadowsocks.json -d start

Oct 20 01:55:28 zhaojun systemd[1]: Starting LSB: Fast tunnel proxy that helps you bypass firewalls...
Oct 20 01:55:28 zhaojun shadowsocks[873]: INFO: loading config from /etc/shadowsocks.json
Oct 20 01:55:28 zhaojun shadowsocks[873]: 2017-10-20 01:55:28 INFO     loading libcrypto from libcrypto.so.10
Oct 20 01:55:28 zhaojun shadowsocks[873]: Starting Shadowsocks success
Oct 20 01:55:28 zhaojun systemd[1]: Started LSB: Fast tunnel proxy that helps you bypass firewalls.

5. Block Storage

由于选择的是**New York(NJ)**的Server,目前免费赠送50G的Block Storage,需要可以手动mount并格式化Block Storage。

  • Attached to Instance

  • Block Storage Information

(Linux) Create partitions:
parted -s /dev/vdb mklabel gpt
parted -s /dev/vdb unit mib mkpart primary 0% 100%

(Linux) Create filesystem:
mkfs.ext4 /dev/vdb1

(Linux) Mount block storage:
mkdir /mnt/blockstorage
echo >> /etc/fstab
echo /dev/vdb1 /mnt/blockstorage ext4 defaults,noatime 0 0 >> /etc/fstab
mount /mnt/blockstorage

6. Shadowsocks服务器端提速优化

  • 安装Google TCP BBR拥塞控制算法,用以加快服务器网速:

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh
chmod +x bbr.sh
./bbr.sh

---------- System Information ----------
 OS      : Ubuntu 16.04.6 LTS
 Arch    : x86_64 (64 Bit)
 Kernel  : 4.15.0-1029-gcp
----------------------------------------
 Auto install latest kernel for TCP BBR

 URL: https://teddysun.com/489.html
----------------------------------------

Press any key to start...or Press Ctrl+C to cancel

Info: Your kernel version is greater than 4.9, directly setting TCP BBR...
Info: Setting TCP BBR completed...

Last updated