1、更新yum  这里可能更新时间有点长,,稳住~别急
yum -y upgrade
2、安装 epel-release 这个必须先安装,因为: python-pip 和 privoxy 都在EPEL源里面,,有的小伙伴可能已经换了国内的源,所以请先检查安装这两个包,以防不测(万一你换的源里没有呢()^_^)
yum install -y epel-release
3、安装 python-pip
yum install -y python-pip

#安装完成后需要更新一下

pip install --upgrade pip
4、安装 shadowsocks 、安装
#install ss
pip install shadowsocks
#install privoxy
yum install -y privoxy
5、配置 shadowsocks
vim /etc/shadowsocks.json
添加以下内容
{
    "server": "156.12.22.29",
    "server_port": "55555",
    "local_address": "127.0.0.1",
    "local_port": "6666",
    "password": "service_password",
    "method": "aes-256-cfb",
    "timeout": "300",
    "workers": "1"
}

每个字段解释

  server :: shadowsocks服务器的ip
  server_port :: shadowsocks服务器端口
  local_address :: 本机监听地址,不需要修改
  local_port :: 本机监听端口,不要和正在使用的端口冲突
  password :: shadowsocks服务器密码
  method :: shadowsocks服务器的加密方式
 
6、配置 privoxy
vim /etc/privoxy/config
# 确认下面这一行没有被注释掉 listen-address 127.0.0.1:8118 ## 默认端口是8118,不需要修改
# 新增一行 forward-socks5t / 127.0.0.1:6666 .
## 端口必须与 /etc/shadowsocks.json 中 local_port 字段的值相同,
## 注意:行尾有一个英文句号(.)
7、启动 shadowsocks+ 测试
# 以 daemon 模式启动
[root@centos-linux ~]# sslocal -c /etc/shadowsocks.json -d start
INFO: loading config from /etc/shadowsocks.json
2019-02-26 23:30:12 INFO loading libcrypto from libcrypto.so.10
started
# 确认 sslocal 已监听在预设端口 lsof -i | grep sslocal
[root@centos-linux ~]# lsof -i | grep sslocal
sslocal 24367 root 4u IPv4 53001198 0t0 TCP localhost:ircu-2 (LISTEN)
sslocal 24367 root 5u IPv4 53001199 0t0 UDP localhost:ircu-2
[root@centos-linux ~]# curl --socks5 127.0.0.1:6666 http://httpbin.org/ip
{
"origin": "156.12.22.29, 156.12.22.29" # 注意 :: 必须与 /etc/shadowsocks.json 中 server 字段的值相同
}
 
8、启动 privoxy +测试
systemctl start privoxy
[root@centos-linux ~]# curl --proxy https://127.0.0.1:8118 -Is https://google.com | grep -w 200
HTTP/1.1 200 Connection established
9、设置开机启动
sh -c 'echo "sudo /usr/bin/sslocal -c /etc/shadowsocks.json -d start" >> /etc/rc.d/rc.local' # 如果 rc.local 没有可执行权限就给它加上
systemctl enable privoxy
10、测试是否能***

#启用代理
export http_proxy='127.0.0.1:8118'
export https_proxy='127.0.0.1:8118'

# 停用代理
export http_proxy=''
export https_proxy=''
curl -I https://golang.org/
#执行命令后出现如下信息,说明成功
[root@centos-linux ~]# curl -I https://golang.org/
HTTP/1.1 200 Connection established

HTTP/1.1 200 OK
Date: Tue, 26 Feb 2019 15:41:47 GMT
Content-Type: text/html; charset=utf-8
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
Transfer-Encoding: chunked
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39"
 
11、为了更方便使用,启动和停用写成一个shell脚本
#创建文件 /etc/profile.d/vm-proxy.sh,文件内容如下
[root@centos-linux ~]# cat /etc/profile.d/vm-proxy.sh
function cmd-proxy-on {
export no_proxy="127.0.0.1,localhost,localaddress,.localdomain.com,tencentyun.com";
export http_proxy='127.0.0.1:8118';
export https_proxy=$http_proxy;
echo 'HTTP proxy started.'
}
export -f cmd-proxy-on

# 第二种声明函数的方式
cmd-proxy-off() {
unset http_proxy;
unset https_proxy;
echo 'HTTP proxy stopped.'
}
export -f cmd-proxy-off
#source 脚本
chmod +x /etc/profile.d/vm-proxy.sh
source /etc/profile.d/vm-proxy.sh
 
最后测试脚本
[root@centos-linux ~]# vim /etc/profile.d/vm-proxy.sh
[root@centos-linux ~]# chmod +x /etc/profile.d/vm-proxy.sh
[root@centos-linux ~]# source /etc/profile.d/vm-proxy.sh
[root@centos-linux ~]# cmd-proxy-on
HTTP proxy started.
[root@centos-linux ~]# curl -I https://golang.org/
HTTP/1.1 200 Connection established

HTTP/1.1 200 OK
Date: Tue, 26 Feb 2019 15:47:18 GMT
Content-Type: text/html; charset=utf-8
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
Transfer-Encoding: chunked
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39"

[root@centos-linux ~]# cmd-proxy-off
HTTP proxy stopped.
[root@centos-linux ~]# curl -I https://golang.org/

curl: (7) Failed connect to golang.org:443; 拒绝连接

centos7 使用ss和Privoxy 实现命令行访问google的更多相关文章

  1. 使用 grpcurl 通过命令行访问 gRPC 服务

    原文链接: 使用 grpcurl 通过命令行访问 gRPC 服务 一般情况下测试 gRPC 服务,都是通过客户端来直接请求服务端.如果客户端还没准备好的话,也可以使用 BloomRPC 这样的 GUI ...

  2. Centos7修改默认启动级别(命令行,图形切换)

    方法一: 终端输入以下命令 修改为命令行方式 systemctl set-default multi-user.target 修改为图形界面 systemctl set-default graphic ...

  3. centos7更改为启动桌面或命令行模式

    进入cenos7的命令行模式 终端输入“init 3”回车进入命令行模式 登录成功后 # systemctl get-default //获取当前系统启动模式 查看配置文件 # cat /etc/in ...

  4. Linux命令行访问网页

    找到个好资料,备份行: http://hi.baidu.com/oyvfhp/blog/item/3aa5ced5b40563d351da4bb0.html   CURL --- 命令行浏览器 这东西 ...

  5. Node.js(window)基础(1)——用cmd命令行访问某一文件夹下的js文件

    一.安装,从官网上下载安装,安装基本一直点击下一步就行.注意:node.js基于Python的,安装node.js之前电脑上要安装Python,最好是Python2.7或2.6. 二.cmd进入命令行 ...

  6. 强悍的 ubuntu —— 命令行访问网页

    所谓以命令行的方式访问网页,即是在终端下以文本的形式访问网站,这里推荐一个工具:w3m, $ sudo apt-get install w3m $ w3m www.baidu.com

  7. thinkphp5命令行访问

    入口文件后加一个空格就行了 1,首先cd到站点目录public下,我的入口文件是默认的index.php,然后执行以下命令, 2,php要加入环境变量 访问index模块下的index控制器下的tes ...

  8. 命令行访问远程mysql数据库

    命令: mysql -u用户名 -p密码 -h远程数据库IP地址 -P端口 -D数据库名 例子: 使用用root帐号,密码为123456,登录ip地址为192.168.1.110,端口为3306,名称 ...

  9. Ubuntu下命令行访问网站

      第一步,需要安装一个名为w3m的软件工具,打开终端,输入如下命令 sudo apt-get install w3m 第二步,安装好w3m之后,在终端里面启动w3m,打开一个网址,比如w3m www ...

随机推荐

  1. OPNET下op_pk_copy()函数使用注意事项

    1)op_pk_copy()是生成新的数据包,函数op_pk_create_time_get()获取的是新数据包的生成时间.在统计数据包的端到端时延,以及服务时延需要注意. 2)此外发用数据包时使用o ...

  2. IDEA overwrite报错、languagelevel设置不生效问题

    发现idea 倒入项目后,发现@override报错,发现是idea的jdk版本不对,需要设置大于1.5的jdk版本 解决办法: IDEA:File >> Project Structur ...

  3. JavaScript数组方法--concat、push

    利用了两天的时间,使用typescript和原生js重构了一下JavaScript中数组对象的主要方法,可以移步github查看. 这里,按照MDN上的文档顺序,再重新学习一下数组方法吧. conca ...

  4. sql优化使用技巧

    1.LIMIT 语句分页查询是最常用的场景之一,但也通常也是最容易出问题的地方.比如对于下面简单的语句,一般 DBA 想到的办法是在 type, name, create_time 字段上加组合索引. ...

  5. springboot学习四:整合mybatis

    在application.properties加入配置 ## Mybatis 配置 mybatis.typeAliasesPackage=org.spring.springboot.domain my ...

  6. 【机器学习_8】pandas

    背景 关于同一个话题,不同作者也有不同行文结构.但要真正理解并会用,在我的经验里,是必须要自己重新组织的. 本文是基于以往看过的资料,从自身数据处理应用的角度出发,重新组织pandas应用结构,希望能 ...

  7. POJ - 3278

    题目链接:http://poj.org/problem?id=3278 ac代码: #include <iostream>#include <stdio.h>#include ...

  8. 开窗函数over

    select   id,sum(je) over() as je from dt

  9. 使用samba 共享Linux文件到Windows

    1.使用yum命令安装了samba服务 #yum install samba 2.配置/etc/samba/smb.conf文件,在最后一行添加下面一段配置: #vi /etc/samba/smb.c ...

  10. leetcode978

    class Solution(object): def maxTurbulenceSize(self, A: 'List[int]') -> int: n = len(A) if n == 1: ...