使用代理上网 - yiyixiaozhi/readingNotes GitHub Wiki


title: 配置代理服务 date: 2020-2-23 description: github网站慢的不行,所以就配置个代理服务器 categories: - 工具 tags: - Shadowsocks

[TOC]

CentOS环境

  • 安装python2
yum install python2.7
  • 安装pip
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
  • 安装shadowsocks
pip install -U pip
  • 新建配置文件(配置端口和密码)
vim /etc/shadowsocks.json

## 配置文件内容:
{
  "server": "0.0.0.0",
  "server_port": 8080,
  "password": "yiyixiaozhi",
  "method": "aes-256-cfb"
}
  • 配置成自启动服务
vim /etc/systemd/system/shadowsocks.service
## 内容如下:
[Unit]
Description=Shadowsocks

[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json

[Install]
WantedBy=multi-user.target

# 执行以下命令启动 shadowsocks 服务:
systemctl enable shadowsocks
systemctl start shadowsocks

参考:

阿里云HK轻量云服务器搭建

安装出错:

No package python27 available

yum install centos-release-scl
s这条命令可以执行安装centos 发行扩展,然后执行yum install python27 python27-devel

yum -y install epel-release
yum -y install python-pip
pip install --upgrade pip
pip install shadowsocks

登录:

frp配置: 10080和20080都做了映射,其中20080端口做成了服务。

[root@izj6c4ty14huv2ax9gtcwsz ~]# vi /usr/local/frp/frp_0.24.1_linux_amd64/frpc.ini

[common]
server_addr = frp2.yyxz.link
server_port = 7000

[hk-10080]
type = tcp
local_ip = 127.0.0.1
local_port = 10080
remote_port = 30081

[hk-20080]
type = tcp
local_ip = 127.0.0.1
local_port = 10080
remote_port = 20080

10080端口的服务参考本文搭建: https://github.com/Alvin9999/new-pac/wiki/%E8%87%AA%E5%BB%BAss%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%95%99%E7%A8%8B 启动命令:

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ssr.sh && chmod +x ssr.sh && bash ssr.sh

启动命令:

nohup /usr/local/frp/frp_0.24.1_linux_amd64/frpc -c /usr/local/frp/frp_0.24.1_linux_amd64/frpc.ini &

安装客户端

参考:

https://woj.app/3857.html

https://brickyang.github.io/2017/01/14/CentOS-7-%E5%AE%89%E8%A3%85-Shadowsocks-%E5%AE%A2%E6%88%B7%E7%AB%AF/

# yum -y install python-pip
# curl http://mirrors.aliyun.com/pypi/simpla/get-pip.py -o get-pip.py
升级版本
# python -m pip install --upgrade pip

# vi /etc/shadowsocks.json
{
  "server":"47.93.195.0",
  "server_port":30082,
  "local_address": "127.0.0.1",
  "local_port":30083,
  "password":"yyxz",
  "timeout":300,
  "method":"aes-256-cfb",
  "workers": 1
}

启动:
nohup sslocal -c /etc/shadowsocks.json &>> /var/log/sslocal.log &

privoxy篇
# yum -y install privoxy
配置 socks5 全局代理
# echo 'forward-socks5 / 127.0.0.1:30083 .' >> /etc/privoxy/config
设置 http/https 代理
# export http_proxy=http://127.0.0.1:8118 # privoxy默认监听端口为8118
# export https_proxy=http://127.0.0.1:8118
运行 privoxy
# service privoxy start

报错解决方法:

[root@localhost ~]# pip install --upgrade pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) 
...
# pip install selectivesearch -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
⚠️ **GitHub.com Fallback** ⚠️