Total Pageviews

Tuesday, 18 September 2018

利用across-by-yueyuzhao翻墙

登陆linux vps.
首先安装nodejs环境。
然后,
mkdir across-by-yueyuzhao
cd across-by-yueyuzhao
wget https://gist.githubusercontent.com/yueyuzhao/c469207dcf8e8c02a9525415deb4bf08/raw/eb31fbc0b7273b3d25fff0505a75682b7be98d43/across.server.js
wget https://gist.githubusercontent.com/yueyuzhao/c469207dcf8e8c02a9525415deb4bf08/raw/eb31fbc0b7273b3d25fff0505a75682b7be98d43/package.json


root@umh:~/across-by-yueyuzhao# ls
across.server.js package.json
root@umh:~/across-by-yueyuzhao# npm install
root@umh:~/across-by-yueyuzhao# mkdir keys
root@umh:~/across-by-yueyuzhao# cd keys
root@umh:~/across-by-yueyuzhao/keys# openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout across.key -out across.pem
(一路回车,即可在当前目录下,生成across.key和across.pem)
root@umh:~/across-by-yueyuzhao/keys# cd ..
root@umh:~/across-by-yueyuzhao#
root@umh:~/across-by-yueyuzhao# nano across.server.js
(把第16行的3738和第29行的3738都改成3739 ,
把第35行的37637和第36行的37637都改成37636)
root@umh:~/across-by-yueyuzhao# node across.server.js
会显示:
server bound 37636
proxy server listening on port 3739


不过这是运行在前台的,容易退出。先按ctrl+c退出。我们可以利用systemd来把node across.server.js运行为service:
nano /etc/systemd/system/across-by-yueyuzhao.service
内容为:
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/across-by-yueyuzhao
ExecStart=/usr/bin/node /root/across-by-yueyuzhao/across.server.js
Restart=always

[Install]
WantedBy=multi-user.target

然后运行:
systemctl start across-by-yueyuzhao
systemctl enable across-by-yueyuzhao
服务器端就搭建完成。

在客户机器mac上。
首先安装nodejs环境。
然后,
mkdir across-by-yueyuzhao
cd across-by-yueyuzhao
wget https://gist.github.com/yueyuzhao/c469207dcf8e8c02a9525415deb4bf08/raw/eb31fbc0b7273b3d25fff0505a75682b7be98d43/across.client.js
nano across.client.js
(把第17行的37637改成37636 ,把第17行的across.local改成你vps的ip ,把第34行的3737改成2727)
node across.client.js
(不要关闭该terminal)

然后设置浏览器的http代理服务器地址为127.0.0.1 ,端口为2727 ,浏览器即可翻墙。

我为何知道要设置浏览器的http代理服务器而非socks代理服务器呢?
那是因为在vps上,
root@umh:~/across-by-yueyuzhao# ls
across.server.js  keys node_modules  package.json
(运行npm install ,就生成了node_modules目录)
root@umh:~/across-by-yueyuzhao# cd node_modules
root@umh:~/across-by-yueyuzhao/node_modules# ls
basic-auth-parser  commander  debug  graceful-readlink ms  proxy
root@umh:~/across-by-yueyuzhao/node_modules# cd proxy
root@umh:~/across-by-yueyuzhao/node_modules/proxy# ls
History.md  README.md  bin  package.json  proxy.js  test
root@umh:~/across-by-yueyuzhao/node_modules/proxy# cd bin
root@umh:~/across-by-yueyuzhao/node_modules/proxy/bin# ls
proxy
root@umh:~/across-by-yueyuzhao/node_modules/proxy/bin# ./proxy
HTTP(s) proxy server listening on port 3128

如果翻墙速度变慢了,那么按ctrl+c,再运行客户端命令:node across.client.js

项目地址:https://gist.github.com/yueyuzhao/c469207dcf8e8c02a9525415deb4bf08
看youtube,还很流畅。

No comments:

Post a Comment