Total Pageviews

Tuesday, 21 August 2018

利用socks代理服务器程序simple-socks翻墙

登陆linux vps.
首先安装nodejs环境。然后,
git clone https://github.com/brozeph/simple-socks simple-socks-by-brozeph
cd simple-socks-by-brozeph

root@umh:~/simple-socks-by-brozeph# ls
examples     history.md package.json
gulpfile.js  lib package-lock.json  readme.md

root@umh:~/simple-socks-by-brozeph# npm install
root@umh:~/simple-socks-by-brozeph# node examples/createServer.js

不过node examples/createServer.js是运行在前台的,且默认监听端口1080.我们按ctrl+c先终止它的运行。

root@umh:~/simple-socks-by-brozeph# grep -ri 1080 examples
examples/createServer.js:server.listen(1080);
examples/createServerConnectionFilter.js:server.listen(1080);
examples/createServerWithAuthentication.js:server.listen(1080);
root@umh:~/simple-socks-by-brozeph# nano examples/createServer.js
(把server.listen(1080); 改为server.listen(10700);

运行node examples/createServer.js ,node监听的端口就变成了10700.不过node examples/createServer.js是运行在前台的,我们可利用systemd来把此命令运行为service:
nano /etc/systemd/system/simple-socks-by-brozeph.service
其内容为:
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/simple-socks-by-brozeph/
ExecStart=/usr/bin/node examples/createServer.js
Restart=always

[Install]
WantedBy=multi-user.target

然后运行,
systemctl start simple-socks-by-brozeph
systemctl enable simple-socks-by-brozeph
服务器端搭建完成。

在本地机器mac上。
在chrome+switchyomega里设置一个代理服务器情景模式。代理协议为socks5,代理服务器的值为vps的ip,代理端口为10700,保存选项,chrome即可翻墙,只是看youtube有点慢。

项目地址:https://github.com/brozeph/simple-socks

No comments:

Post a Comment