无成本部署本地大模型供外网访问,核心是使用 Cloudflare Tunnel,本地ollama提供api服务,通过内网穿透实现外网访问。
Cloudflare Tunnel:通过Cloudflare的内网穿透服务,帮助我们将本地的服务暴露到外网,避免需要公网IP。
brew install cloudflare
创建 Tunnel 配置文件: 使用 Cloudflare Tunnel 的命令行工具配置一个隧道。执行如下命令:
cloudflared tunnel --url http://localhost:11434
这会将你本地的11434端口映射到Cloudflare的网络,生成一个可公开访问的URL。
确认 Tunnel 启动:
Cloudflare Tunnel启动后,它会给你一个访问URL。你可以在浏览器中访问这个URL来验证配置是否成功。