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 ...
随机推荐
- golang初识5 - interface
1. interface-new (1) abstract format: type abstractName interface { method_name1 [return_type] } (2) ...
- qt button clicked(bool) always false
今天用 qt 中的按键的时候,希望按键有两种状态,通过 clicked(bool) 发送信号给槽,结果一直发的是 false,不能为 true,后来终于找到问题了,有两种解决方法. 在 button ...
- Rabbitmq 安装后采坑
一.接手项目 接手项目后,按别人说的先安装什么,后安装什么然后就可以用了,也不去看什么.先开始安装的是otp_win64_19.1工具包和rabbitmq-server-3.6.5服务端,在win10 ...
- python3 在文件确实存在的情况下,运行提示找不到文件
提示 [Errno 2] No such file or directory: 但是路径下确实存在此文件,在不改动的情况下,再次运行,执行成功. 百思不得其解,看到此链接下的回答 http://bbs ...
- python练习题_03
1.写函数: 根据范围获取其中3和7整除的所有数的和,并返回调用者: 符合条件的数字个数以及符合条件的数字的总和,如:def func(start,end): def func(start,end): ...
- 把nginx当完全tcp端口转发器
在nginx.conf里加入 stream { server { listen 18443; proxy_pass 58.xxx.xxx.xxx:8443; ...
- Druid中配置双数据库
配置如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://w ...
- 基于MGR+Atlas的读写分离尝试,以及MGR+Keepalived+Atlas自动故障转移+读写分离设想
目的是尝试altas的读写分离,现有一套搭建好做测试的MGR(单主),于是就腿搓绳,在MGR基础上搭建altas. 复制环境准备 读写分离理论上讲,跟复制模式没有关系,atlas负责的是重定向读写,至 ...
- Django启动报错笔记
NO.1: You have 15 unapplied migration(s). Your project may not work properly until you apply the mig ...
- HC-05蓝牙模块配对步骤
参考:https://blog.csdn.net/m0_37182543/article/details/76383247