Network Security And CORS

Open Ollama to your network safely with host binding, CORS origins, and an authenticating proxy.

TL;DR

  1. Set OLLAMA_HOST=0.0.0.0 to expose the server on your LAN.
  2. Limit browser callers with the OLLAMA_ORIGINS CORS allowlist.
  3. Never expose port 11434 publicly without an auth proxy.

Bind The Host

    Local Only

    The default binds to localhost for safety.

    # Default: OLLAMA_HOST=127.0.0.1
    Expose On LAN

    Bind all interfaces to reach other machines.

    export OLLAMA_HOST=0.0.0.0:11434
    Pick A Port

    Change the port if 11434 is taken.

    export OLLAMA_HOST=0.0.0.0:8080

CORS With Origins

    OLLAMA_ORIGINS

    Allowlist web origins that may call the API.

    export OLLAMA_ORIGINS=https://app.me.com
    Multiple Origins

    Separate several origins with commas.

    export OLLAMA_ORIGINS=https://a.com,https://b.com
    Avoid Wildcard

    Do not use a star in production.

    # Avoid OLLAMA_ORIGINS=*

Protect The Endpoint

    No Built-in Auth

    The API trusts anyone who can reach it.

    # Ollama has no API key or login
    Auth Proxy

    Put an authenticating reverse proxy in front.

    # Nginx/Caddy with basic or token auth
    Firewall It

    Block 11434 from the public internet.

    # Allow only LAN or VPN to 11434

Safe Exposure

    Use A VPN

    Reach the server over a private network.

    # Expose via VPN, not the open web
    TLS Termination

    Terminate HTTPS at the proxy.

    # Proxy adds TLS in front of 11434
    Rate Limit

    Throttle requests at the proxy layer.

    # Limit requests per IP at the proxy

Tips

  1. Keep OLLAMA_HOST bound to 127.0.0.1 unless you truly need LAN access, since the API has no authentication of its own.
  2. Set OLLAMA_ORIGINS to your specific trusted domains, so only approved web pages can call the server from a browser.

Warnings

  1. Ollama has no built-in auth; exposing port 11434 to the internet lets anyone run your models and read your prompts.
  2. Setting OLLAMA_ORIGINS=* lets any website call your local server from a browser; scope it to trusted origins instead.

In Practice

FAQ