Created
December 9, 2014 17:14
-
-
Save jasonet/7561831300f265c0184b to your computer and use it in GitHub Desktop.
用 Stunnel 保护隐私
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stunnel 是个好东西,很小巧,它的原理是把服务器端的 http 代理加密成 https 代理,然后在本地也用 stunnel 把 https 代理转成 http 代理,这样在本地就有了一个 http 代理可用。goagent限制太多,自己搭建的服务器就是得花钱和浪费点时间。不过值得,相信我。 | |
服务器端搭建: | |
1,http代理,用squid、polipo或者tinyporxy随便搞个http代理出来,此时这个代理是http的,直接用会被rst。 | |
2,安装 stunnel ,配置大概如下,先用 openssl 产生一个证书: | |
openssl req -new -x509 -days 365 -nodes -out /etc/stunnel.pem -keyout /etc/stunnel.pem | |
cert = /etc/stunnel.pem | |
chroot = /var/run/stunnel4/ | |
pid = /stunnel.pid | |
client = no | |
sslVersion = SSLv3 | |
socket = l:TCP_NODELAY=1 | |
socket = r:TCP_NODELAY=1 | |
socket = l:SO_LINGER=1:1 | |
socket = r:SO_LINGER=1:1 | |
[http] | |
accept = 8888 #stunnel的端口 | |
connect = 127.0.0.1:3128 #本地http端口 | |
然后启动 stunnel,服务器端就搭建好了。但此时代理是https的,必须在本地做好了 stunnel 客户端转成 http 才行。 | |
本地端: | |
本地端其实超级简单了。Mac上直接用 macport,brew 安装个 stunnel 即可。如果不便,直接下我的编译好的,在这。下载后 chmod +x stunnel | |
写一个配置文件: | |
client = yes #扮演客户端啦 | |
pid=/var/run/stunnel.pid | |
debug = 7 | |
foreground = no #是否前台运行还是后台运行 | |
sslVersion = SSLv3 | |
verify=0 | |
[proxy] | |
accept = 127.0.0.1:9999 | |
connect = xxx.xxx.xxx.xxx:8888 | |
然后启动 stunnel 即可,执行 ./stunnel stunnel.conf | |
这样,在本地就有一个 9999 端口的 http 代理,世界清净了,没有 rst 和偷窥 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment