# linux环境shadowsocks&privoxy代理

# 命令行配置ss客户端+privoxy创建http代理

  • 安装shadowsocks客户端

    yum install epel-release
    yum repolist 
    yum install python-pip
    pip install --upgrade pip
    pip install shadowsocks
    
  • 配置/etc/shadowsocks.json。

    {
        "server":"代理服务器IP地址",
        "server_port":"服务器端口",
        "local_address":"127.0.0.1",
        "local_port":1080,
        "password":"连接代理需要的密码",
        "timeout":300,
        "method":"加密方式",
        "fast_open":false,
        "workers":1
    }
    
  • 启动ss客户端

    nohup sslocal -c shadowsocks.json /dev/null 2>&1 &
    
  • sslocal使用

    sslocal -h
    usage: sslocal [OPTION]...
    Proxy options:
      -c CONFIG              path to config file
      -s SERVER_ADDR         server address
      -p SERVER_PORT         server port, default: 8388
      -b LOCAL_ADDR          local binding address, default: 127.0.0.1
      -l LOCAL_PORT          local port, default: 1080
      -k PASSWORD            password
      -m METHOD              encryption method, default: aes-256-cfb
      -t TIMEOUT             timeout in seconds, default: 300
      --fast-open            use TCP_FASTOPEN, requires Linux 3.7+
    
    General options:
      -h, --help             show this help message and exit
      -d start/stop/restart  daemon mode
      --pid-file PID_FILE    pid file for daemon mode
      --log-file LOG_FILE    log file for daemon mode
      --user USER            username to run as
      -v, -vv                verbose mode
      -q, -qq                quiet mode, only show warnings/errors
      --version              show version information
    
    
  • 安装privoxy软件,将socks5代理转成http代理

    yum info privoxy
    yum install -y privoxy
    
  • 配置/etc/privoxy/config

    #修改绑定地址,搜索listen-address,修改绑定IP
    listen-address 0.0.0.0:8118
    #设置socks5转发,搜索forward-socks5t,去掉注释,修改IP
    forward-socks5t / 127.0.0.1:1080 .
    #配置不走代理直接转发IP
    forward    192.168.*.*/       .
    forward    10.*.*.*/          .
    forward    127.*.*.*/         .
    #增加重试次数,默认为0
    forwarded-connect-retries  3
    #增加最大客户端连接数,默认128
    max-client-connections 10
    开启和关闭广告过滤,1开启0关闭,默认1
    toggle  0
    
  • 启动privoxy服务

    systemctl start privoxy
    systemctl status privoxy
    
  • 修改环境变量(命令行上网)

    export http_proxy=http://127.0.0.1:8118
    export https_proxy=http://127.0.0.1:8118
    export ftp_proxy=http://127.0.0.1:8118
    
  • 检查测试

    netstat -an |grep 8118
    curl www.facebook.com
    
  • 浏览器访问

    #设置浏览器代理指向privoxy的8118端口
    #打开http://privoxy地址/ 看是否正常打开privoxy的管理页面。