Ollama 默认是仅本地访问,接口地址是:http://localhost:11434
开放外部访问需要设置两个环境变量:
OLLAMA_HOST=0.0.0.0
OLLAMA_ORIGINS=*
第一步,设置环境变量
macOS:
在终端中运行命令
launchctl setenv OLLAMA_HOST "0.0.0.0"
launchctl setenv OLLAMA_ORIGINS "*"
Windows:
打开“环境变量”配置框
添加两个用户变量:
Linux:
使用 systemctl 设置环境变量
调用 systemctl edit ollama.service 编辑 systemd 服务配置
在 [Service] 下方添加:
[Service]
Environment="OLLAMA_HOST=0.0.0.0"
Environment="OLLAMA_ORIGINS=*"
第二步,重启 Ollama
环境变量配置完成后,重启 Ollama。
第三步,开放防火墙端口
Windows:
进入“高级安全 Windows Defender 防火墙” → “入站规则” → 新建规则 → 允许 TCP 端口 11434。
第四步,验证
获取本机局域网 IP。
Windows:ipconfig
Linux/macOS:ifconfig
访问网址:http://<ip>:11434
若返回 Ollama is running 则表示连接正常。

xoyozo
14 天前
328
ueditor.all.min.js: Uncaught DOMException: Blocked a frame with origin "http://localhost:4492" from accessing a cross-origin frame.
at baidu.editor.ui.Dialog.close
当引用第三方 CDN 静态资源的方式部署百度编辑器时,使用多图上传、涂鸦等功能(弹出框使用 iframe 标签引用 CDN 上的网页)会报上述跨域错误。
官方并没有给出这种部署方案(即客户端页面与页面之间的 iframe 跨域)的完美跨域方法。
但官方针对服务端和客户端分离的跨域情形进行了说明:

xoyozo
5 年前
4,888