My budget VPS had ports 80/443 blocked by NAT — here's the architecture that got my site online
说明与用途
问题:公共VPS因NAT阻止了80/443端口的入站流量。解决方案:使用Cloudflare的出站隧道(cloudflared)、Caddy的DNS‑01 ACME以及Tailscale进行私有访问。配置后网站可访问,SSH/DB保持受保护。
问题
Public HTTP/HTTPS traffic could not reach the VPS because the provider’s 1:N NAT blocked inbound connections on ports 80/443.
结果
The site became reachable over HTTPS without paying for a public IP or opening inbound ports, while SSH and database access remained isolated to the Tailscale mesh.
工作流
- 1. Verify DNS and local firewall settings.
- 2. Inspect network interfaces; discover eth0 has private 10.x.x.x address due to provider NAT.
- 3. Confirm Caddy works locally with curl --resolve.
- 4. Deploy cloudflared daemon to establish outbound tunnel to Cloudflare.
- 5. Configure Cloudflare Tunnel ingress with originServerName to match Caddy’s SNI.
- 6. Set up Caddy with DNS‑01 ACME (Cloudflare API) and reverse_proxy to localhost:3000.
- 7. Enable Tailscale; bind SSH to tailscale0 interface only.
- 8. Disable public inbound ports on eth0.
- 9. Adjust Cloudflare settings: turn off Bot Fight Mode, set cache‑control for static assets.
- 10. Create verification script to check services and local TLS.
- 11. Test and iterate until stable.
证据
The interface (eth0) didn't carry the public IP shown on my invoice. Instead, it held an address in the carrier-grade/shared range: 10.x.x.x (or 100.64.x.x).
The TLS handshake succeeded immediately. Caddy served the certificate, completed the negotiation, and returned the payload without complaint.
Once the tunnel came up, requests through the browser threw immediate 502 Bad Gateway errors.
- 记录日期: 2026-11-02T09:59:07.150Z