本文摘要

  • 什么是 Shadowsocks,它有什么用
  • 如何在 VPS 上部署 Shadowsocks
  • 如何在 iOS 设备上使用 Shadowsocks
  • 如何在 X OS 上安装启动 Shadowsocks 客户端 GoAgentX

ShadowSocks 简介

  • 一个用 Python 写的 socks 加密代理,可以用来欺骗 GFW
  • 作者 clowwindy 在 v2ex 上发布 shadowsocks 原帖地址
  • shadowsocks 在 Github 的 地址

部署安装 ShadowSocks

在 VPS(Ubuntu 12.04 LTS)上部署ShadowSocks

  • 目前 shadow socks 的服务器端有7个不同版本,我用的是原始 Python version,安装其他版本可以参考这里
  • 用 pip 安装 shadowsocks

    sudo pip install shadowsocks
    
  • 在某个文件夹(/your/path/)下创建配置文件config.json文件

    {
      "server":"IP地址",
      "server_port":8388,
      "local_port":1080,
      "password":"你的密码",
      "timeout":600,
      "method":"加密方式"
    }
    
    • server – 填写你的 vps 地址
    • server_port – 用默认的8388
    • local_port – 用默认的1080
    • password – 填写密码
    • timeout – 填写超时时间(秒)
    • method – 填写加密方式,这里推荐用aes-256-cfb
    • 填写时注意 json 文件格式,不要填错,可以用这个工具进行检查
  • 我的配置文件如下:

    {
      "server":"106.186.xx.xx",
      "server_port":8388,
      "local_port":1080,
      "password":"xxxxxxx",
      "timeout":600,
      "method":"aes-256-cfb"
    }
    
  • 安装 M2Crypto 用于加密

    sudo apt-get install python-m2crypto
    
  • 安装 gevent 提升 Shadowsocks 性能

    sudo apt-install python-gevent
    
  • 配置完环境,在/your/path/(config.json 文件同目录下)试运行一下

    ssserver
    
    • 运行成功显示如下

      2013-11-18 07:51:26 INFO     loading config from config.json
      2013-11-18 07:51:26 INFO     starting server at xxx.xxx.xxx.xxx:8388
      
  • 到此为止,VPS 上的配置已经完成了,如果你需要后台启动或者开机运行 shadowsocks,可以配合 supervisor 进行管理

    • 进入 supervisor 的配置文件目录 – cd /etc/
    • 编辑 supervisord.conf 文件 – sudo vi supervisord.conf
    • 插入以下命令

      [program:shadowsocks]
      command=ssserver -c /home/kavi/conf/config.json
      autorestart=true
      user=nobody
      
    • 保存后退出 vim,并重新启动 supervisor – sudo supervisorctl reload

    • 这样 shadowsocks 就成功启动,用以下命令查看状态

      supervisorctl status
      supervisorctl tail shadowsocks
      
  • 完成 VPS 端设置

安装 Shadowsocks 客户端

在 iOS 中用 shadowsocks 浏览网页

  • 在 iOS 设备上,下载Shadowsocks 应用
  • 在 Proxy Settings 中正确填写刚才设置的信息
  • Enjoy it!
    image

在 OS X 下,用 GoAgentX 代理

  • 安装 Python gevent
  • 继续在 Mac 上安装 M2Crypto,之前用 pip 安装,但是出现了错误,在 v2ex 上提问,答案是用 easy_install 重新安装一次就 ok 了,事实果然如此 – sudo easy_install M2Crypto
  • 下载 GoAgentX
  • 安装打开界面,填入之前服务器上 config.json 文件中的参数 image
  • 填入参数之后,点击 Advanced… -> Advanced Configuration -> Program Type -> shadowsocks-python
  • 其他参数默认,返回上层启动 OFF -> ON

Enjoy it!

image