Skip to content

Instantly share code, notes, and snippets.

@sirodoht
Last active March 10, 2024 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirodoht/69d88db69679b4cddbc022af1378c642 to your computer and use it in GitHub Desktop.
Save sirodoht/69d88db69679b4cddbc022af1378c642 to your computer and use it in GitHub Desktop.
Caddyfile for ollama with basic auth
# /etc/caddy/Caddyfile
api.example.com:443 {
route {
@options method OPTIONS
handle @options {
header Access-Control-Allow-Origin "https://clientwebsite.com"
header Access-Control-Allow-Methods "POST"
header Access-Control-Allow-Headers "authorization"
header Access-Control-Allow-Credentials true
respond "" 204
}
header ?Access-Control-Allow-Origin "https://clientwebsite.com"
header Access-Control-Allow-Methods "POST"
header Access-Control-Allow-Headers "authorization"
header Access-Control-Allow-Credentials true
basicauth {
admin $2a$14$xxx
}
reverse_proxy 127.0.0.1:11434
}
}
# /etc/systemd/system/ollama.service.d/environment.conf
# https://github.com/jmorganca/ollama/blob/2a2fa3c3298194f4f3790aade78df2f53d170d8e/docs/faq.md#how-do-i-use-ollama-server-environment-variables-on-linux
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_ORIGINS=http://192.168.1.1:*,https://clientwebsite.com:*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment