Skip to content
Discussion options

You must be logged in to vote

配置 Ollama 允许跨域访问

由于 Ollama 的默认参数配置,启动时设置了仅本地访问,所以跨域访问以及端口监听需要进行额外的环境变量设置 OLLAMA_ORIGINS。

在 macOS 下使用 Ollama

使用 launchctl 设置环境变量:

launchctl setenv OLLAMA_ORIGINS "*"

完成设置后,需要重启 Ollama 应用程序。

在 Windows 下使用 Ollama

Ollama 继承了您的用户和系统环境变量。

首先通过 Windows 任务栏点击 Ollama 退出程序。
从控制面板编辑系统环境变量。
为您的用户账户编辑或新建 Ollama 的环境变量 OLLAMA_ORIGINS,值设为 * 。
点击OK/应用保存后重启系统。

完成设置后,需要重启 Ollama 应用程序。

在 linux 下使用 Ollama

如果 Ollama 作为 systemd 服务运行,应该使用systemctl设置环境变量:

通过调用sudo systemctl edit ollama.service编辑 systemd 服务。

sudo systemctl edit ollama.service

对于每个环境变量,在[Service]部分下添加Environment:

[Service]
Environment="OLLAMA_HOST=0.0.0.0"
Environment="OLLAMA_ORIGINS=*"

保存并退出。

重载 systemd 并重启 Ollama:

sudo systemctl daemon-reload
…

Replies: 11 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@richardy2012
Comment options

Comment options

You must be logged in to vote
1 reply
@emptystack1024
Comment options

Comment options

You must be logged in to vote
5 replies
@zzc-1024
Comment options

@emptystack1024
Comment options

@codexu
Comment options

@emptystack1024
Comment options

@codexu
Comment options

Comment options

You must be logged in to vote
2 replies
@codexu
Comment options

@Mczye
Comment options

Comment options

You must be logged in to vote
2 replies
@LloydLore
Comment options

@wookkkkk
Comment options

Comment options

You must be logged in to vote
1 reply
@wookkkkk
Comment options

Answer selected by codexu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants
Converted from issue

This discussion was converted from issue #57 on February 27, 2025 00:25.