Written by Zhong Wei
半年多前配过一次,磕磕绊绊的,勉强配好了能用。这次老朋友又买了一台类似的机器,我以为会很快搞定,结果又陆续整了好几个小时。为避免下次折腾的时候浪费时间,简要记录一下折腾过程。
用到的软件
- shadowsocks-libev-local
- kcptun-client
几个要点
- 需要下载的软件只有这俩,一开始没有下载 shadowsocks-libev-local而是尝试用机器里已经下载好的 shadowsocksR-local 代替,未成功(并不一定是ssR的锅....
- 下载了kcptun,也配置了使用 kcptun,但kcptun服务一直不启动的原因是kcptun客户端的程序名字与系统中设置的不一致。安装好的客户端名字叫 kcptun-c 但默认配置的名字不是这个,务必要到「自动更新」那一页改一下配置。
- 「全局配置」页配置:
- TCP节点:SS+Kcptun: 节点名
- UDP节眯:与TCP节点相同
- Socks5节点:与TCP节点相同
- DNS服务器(UDP): 默认
- DNS模式: DNS2SOCKS + 使用Socks5节点解析
- DNS地址:8.8.4.4 (Google DNS)
- DNS劫持: 选中
- 默认代理模式: GFW列表 (重要...尤其远程调试的时候,别瞎选全局...配不好的情况下一开代理,网会断,波及远程桌面!
- 本机代理模式: GFW列表
- 「节点页」配置:
- 服务器: 127.0.0.1
- 使用ipv6: 不选中
- 端口: kcptun 客户端打算用的端口
- 加密方式: ss服务器用到的加密方式
- 连接超时: 300 (默认值不用改
- tcp快速打开: false (默认值不用改
- 插件: 无
- 使用kcptun: checkbox要勾中(废话
- kcptun服务器: 你的kcptun服务器IP或域名
- 使用ipv6: 不选中
- kcptun参数配置: 把kcptun服务器配置的那堆参数照抄过来(只要端口参数之外的参数,一定要拿掉 -r -l 这两参数哦!
回头看看也没什么.....就这么点事儿,整了几个小时。如果第一次整完就写篇备忘记录....哈,亡羊补牢,犹未晚,我这不就写了么!
Written by Zhong Wei
To be honest, 5 minutes is not enough, especially for the first time you do it.
What you need to prepare
- a VPS (Virtual Personal Server) with public IP
- an Nginx Server running on that VPS.
- an OpenVPN Server running on that VPS. (or you have tailscale service running on both your local machine & the VPS server)
- a domain name
- the CertBot tool from Let's Encrypt
Steps to get it to work
For example,
- your local dev environment is running on
10.8.0.2:8080
- your domain name is
dev.myawesomedomain.com
- create a new virtual server on your Nginx server, you can use the config below as a template.
upstream local-front-end-env {
server 10.8.0.2:8080;
}
server {
listen 80;
listen [::]:80;
server_name dev.myawesomedomain.com;
access_log /var/log/nginx/dev.myawesomedomain.com.access.log;
error_log /var/log/nginx/dev.myawesomedomain.com.error.log;
location / {
proxy_pass http://local-fornt-end-env;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# the following lines is used to support wss:// protocol
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
large_client_header_buffers 4 32k;
}
- run
sudo certbot --nginx
to automatically config your new-added virtual server.
- run
sudo nginx -s reload
& test it in browser
- You need to modify your package.json to listen your vpn IP
- "serve": "vue-cli-service serve",
+ "serve": "vue-cli-service serve --host=0.0.0.0 --port=8080 --public=https://dev.myawesomedomain.com",
- You may need to modify your
vue.config.js
to fix the "Invalid Host header" error when visiting your site by https instead of localhost:8080
.
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,6 +1,9 @@
module.exports = {
configureWebpack: {
externals: {
+ },
+ devServer: {
+ disableHostCheck: true
}
},
That's it.
Written by Zhong Wei
Tailscale
丁宇在推特上说这个东东比 frp 好用。我先一口气把它安装到四台服务器性质的 Linux 机器上,包括两台本来就有外网 IP 的vps,然后才琢磨这东西有啥用,怎么用。安装和授权过程都很简洁,没有废话,第一印象棒极了。
那...它有啥用呢?一句话,它把你所有的机器,不论物理上隔多远,放到一个局域网里了。在这个局域网里,没有防火墙,网内可以访问任何设备的任何端口。和普通的vpn不同,它没有中央设备,所有设备之间都是直连,因此性能比较好。
那有啥用呢?
- 管理你的一堆机器更方便了。
- 局域网内任何一台有外网IP的机器都能做为任何一台内网机器的跳板机(内网无端口限制的穿透)。
换言之,你的VPS只要有足够的流量,硬盘空间不再是限制你部署应用的瓶颈,你完全可以把你的各种试验性side project部署在你的家里,或者父母的家里,扔台旧机器装个Linux就全齐活了。
嗯,它不光支持 Linux,还支持macOS,iOS,Windows!牛大了。
记录一下小坑。macOS 10.15.4 安装好后 Login 是灰的,无法登录,重启下电脑就好了。