centos7 使用ss和Privoxy 实现命令行访问google
yum -y upgrade
yum install -y epel-release
yum install -y python-pip
#安装完成后需要更新一下
pip install --upgrade pip
#install ss pip install shadowsocks #install privoxy yum install -y privoxy
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"
}
每个字段解释
vim /etc/privoxy/config # 确认下面这一行没有被注释掉 listen-address 127.0.0.1:8118 ## 默认端口是8118,不需要修改 # 新增一行 forward-socks5t / 127.0.0.1:6666 . ## 端口必须与 /etc/shadowsocks.json 中 local_port 字段的值相同, ## 注意:行尾有一个英文句号(.)
# 以 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 字段的值相同
}
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
sh -c 'echo "sudo /usr/bin/sslocal -c /etc/shadowsocks.json -d start" >> /etc/rc.d/rc.local' # 如果 rc.local 没有可执行权限就给它加上 systemctl enable privoxy
#启用代理 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"
#创建文件 /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的更多相关文章
- 使用 grpcurl 通过命令行访问 gRPC 服务
原文链接: 使用 grpcurl 通过命令行访问 gRPC 服务 一般情况下测试 gRPC 服务,都是通过客户端来直接请求服务端.如果客户端还没准备好的话,也可以使用 BloomRPC 这样的 GUI ...
- Centos7修改默认启动级别(命令行,图形切换)
方法一: 终端输入以下命令 修改为命令行方式 systemctl set-default multi-user.target 修改为图形界面 systemctl set-default graphic ...
- centos7更改为启动桌面或命令行模式
进入cenos7的命令行模式 终端输入“init 3”回车进入命令行模式 登录成功后 # systemctl get-default //获取当前系统启动模式 查看配置文件 # cat /etc/in ...
- Linux命令行访问网页
找到个好资料,备份行: http://hi.baidu.com/oyvfhp/blog/item/3aa5ced5b40563d351da4bb0.html CURL --- 命令行浏览器 这东西 ...
- Node.js(window)基础(1)——用cmd命令行访问某一文件夹下的js文件
一.安装,从官网上下载安装,安装基本一直点击下一步就行.注意:node.js基于Python的,安装node.js之前电脑上要安装Python,最好是Python2.7或2.6. 二.cmd进入命令行 ...
- 强悍的 ubuntu —— 命令行访问网页
所谓以命令行的方式访问网页,即是在终端下以文本的形式访问网站,这里推荐一个工具:w3m, $ sudo apt-get install w3m $ w3m www.baidu.com
- thinkphp5命令行访问
入口文件后加一个空格就行了 1,首先cd到站点目录public下,我的入口文件是默认的index.php,然后执行以下命令, 2,php要加入环境变量 访问index模块下的index控制器下的tes ...
- 命令行访问远程mysql数据库
命令: mysql -u用户名 -p密码 -h远程数据库IP地址 -P端口 -D数据库名 例子: 使用用root帐号,密码为123456,登录ip地址为192.168.1.110,端口为3306,名称 ...
- Ubuntu下命令行访问网站
第一步,需要安装一个名为w3m的软件工具,打开终端,输入如下命令 sudo apt-get install w3m 第二步,安装好w3m之后,在终端里面启动w3m,打开一个网址,比如w3m www ...
随机推荐
- linux ubuntu生成pac文件,实现代理
sudo pip install genpac sudo pip install --upgrade genpac sudo genpac --proxy="SOCKS5 127.0.0.1 ...
- Android 开发 values目录里定义数组、颜色、文本、尺寸xml配置文件并且获取数据 附录Android符号转码表
以下xml都在res/values/文件夹下创建 创建String类型array: /app/src/main/res/values/array.xml <?xml version=" ...
- Convert Adjacency matrix into edgelist
Convert Adjacency matrix into edgelist import numpy as np #read matrix without head. a = np.loadtxt( ...
- matlab-逻辑回归二分类(Logistic Regression)
逻辑回归二分类 今天尝试写了一下逻辑回归分类,把代码分享给大家,至于原理的的话请戳这里 https://blog.csdn.net/laobai1015/article/details/7811321 ...
- 分布式 基本理论 CAP
谈及分布式,必然谈到 CAP, CAP 已经是被说烂了的一个 话题, 绕不开, 逃不掉. 而且, 理解起来 会有些吃力. 分布式的CAP理论告诉我们 “任何一个分布式系统都无法同时满足 一致性(Co ...
- supergridcontrol记录
单元格换行: this.gridColumn2.CellStyles.Default.Alignment = DevComponents.DotNetBar.SuperGrid.Style.Align ...
- React props
class WebSite extends React.Component { constructor() { super(); this.state = { name: "菜鸟教程&quo ...
- js 手写 Promise
/* * pending:初始化成功 * fulfilled:成功 * rejected:失败 * */ function Promise(cback){ this.status = 'pending ...
- User authentication in Django(用户认证)
一,概述: auth 系统包括: 1)Users 2)Permissions: Binary (yes/no) flags designating whether a user may perform ...
- shell 批量删除所有指定名字的目录
例如删除当前目录下所有名字为DerivedData的目录 find . -name "DerivedData" -type d -exec rm -r "{}" ...