Set up my own VPS
My first try to access google is to set up VPS, but at that time I’m so naive. Today, after several years of learning, I come back again.
Before Setup VPS
At the very beginning, if you don’t get a block from the GFW just after you setup the VPS, I suggest using a relatively complex protocol to protect your network data.
Then you need a domain, and a DNS server.
I choose namesilo as provider and got the domain and DNS service from it.
Virtual Private Server (VPS)
I choose Vultr as the provider, as I used it at the very beginning and I have the account.
Then choose the cheapest scheme.
Trojan-go
I choose Trojan-go as server which works on Vultr server.
Setting up auto restart Service
File: /etc/systemd/system/trojan-go.service
1 | [Unit] |
Enable and start the service
1 | sudo systemctl daemon-reload |
systemd will restart the process after it quit in 5 seconds.
Build up nginx server
HTTPS using Nginx and Let’s encrypt in Docker
set Let’s encrypt automate refresh
docker-compose
are used by ubuntu. On other OS might be docker compose
1 | 0 2 1 * * docker-compose run --rm certbot renew >> /var/log/certbot-renew.log 2>&1 |
Tech referance
Trouble Shooting
Issue 1
现象
客户端部分网页无法访问,部分可以。
Issue
服务器端
1 | root@vultr:~# nslookup www.booth.pm |
Solution
这是 Ubuntu 默认的 DNS 机制在作怪,不是“坏掉的 127.0.0.1”。
为什么是 127.0.0.53?
Ubuntu 使用 systemd-resolved 作为本地 DNS 缓存/转发器,它在本机回环地址 127.0.0.53:53 上提供“stub resolver”。
/etc/resolv.conf 通常会指向这个本地 stub。真正的上游 DNS(比如 8.8.8.8)由 systemd-resolved 通过 DHCP/Netplan/配置文件获得,再去查询。
你现在的报错:
1 | communications error to 127.0.0.53#53: timed out |
说明要么 systemd-resolved 没在跑、挂了,或被防火墙/网络阻断;要么它没有任何可用的上游 DNS。
快速自检与临时修复
1) 看服务是否在跑
1 | systemctl status systemd-resolved |
2) 若异常,重启并清缓存
1 | sudo systemctl restart systemd-resolved |
3) 看上游 DNS 与接口绑定情况
1 | resolvectl status |
4) 检查 resolv.conf 是否正确指向 stub
1 | ls -l /etc/resolv.conf |
5) 测试直接查 8.8.8.8(绕过本地 stub)
1 | dig @8.8.8.8 www.booth.pm +short |
确保 /etc/resolv.conf 指向 stub-resolv.conf(见上面第 4 步)。
What I saw
Before
1 | root@vultr:~/workspace/trojan-go-app# resolvectl status |
After
1 | root@vultr:~/workspace/trojan-go-app# resolvectl status | sed -n '1,80p' |