LogoOllaMan Docs

Server Authentication Setup

Configure Basic Auth, Bearer token, or custom header authentication for Ollama servers

Overview

OllaMan supports four authentication schemes for connecting to protected Ollama servers:

SchemeUse caseHeader sent
NoneLocal or trusted intranetnone
Basic AuthSelf-hosted reverse proxy (Nginx, Caddy, etc.)Authorization: Basic <base64(user:pass)>
Bearer TokenAPI gateway / Cloudflare Tunnel requiring token authAuthorization: Bearer <token>
Custom HeadersGateways that don't use Authorization, e.g. Cloudflare Accessarbitrary key/value pairs like CF-Access-Client-Id / CF-Access-Client-Secret

Since Ollama itself doesn't provide authentication, you need to put it behind a reverse proxy or gateway. The sections below cover common server-side setups first, then how to pick the matching scheme in OllaMan.


When to Use Authentication

You should enable authentication for your Ollama server in the following scenarios:

  • Server exposed to the internet: Any server accessible from the public internet should be protected
  • Multiple users accessing the same server: Prevent unauthorized access and abuse
  • Security policy requirements: Organizational or team security standards require authentication
  • Protecting sensitive models: When running proprietary or sensitive AI models

Configuring Authentication for Ollama

Using Nginx with Basic Auth

Nginx is the most commonly used reverse proxy server. Here's the complete configuration guide:

Install Required Tools

First, ensure Nginx and Apache utilities (for generating password files) are installed:

# Ubuntu/Debian
sudo apt update
sudo apt install nginx apache2-utils

# macOS
brew install nginx

Create Password File

Use the htpasswd command to create authentication users and passwords:

sudo htpasswd -c /etc/nginx/.htpasswd username

The system will prompt you to enter a password. To add more users, omit the -c flag:

sudo htpasswd /etc/nginx/.htpasswd another_user

Configure Nginx Reverse Proxy

Create or edit the Nginx configuration file (e.g., /etc/nginx/sites-available/ollama):

server {
    listen 8080;
    server_name your-server-domain.com;

    location / {
        # Enable Basic Auth
        auth_basic "Ollama Server";
        auth_basic_user_file /etc/nginx/.htpasswd;

        # Proxy to Ollama default port
        proxy_pass http://localhost:11434;

        # Required proxy headers
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Handle WebSocket connections (if needed)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Timeout settings (large model inference may take time)
        proxy_read_timeout 300s;
        proxy_connect_timeout 75s;
    }
}

Port explanation: In this configuration, Nginx listens on port 8080 and forwards to Ollama's default port 11434. Ollama remains running on localhost:11434 without any configuration changes. Clients access via http://your-server:8080.

Enable and Restart Nginx

# Create symbolic link (Ubuntu/Debian)
sudo ln -s /etc/nginx/sites-available/ollama /etc/nginx/sites-enabled/

# Test configuration
sudo nginx -t

# Restart Nginx
sudo systemctl restart nginx

Test Authentication Setup

Use curl to test if Basic Auth is working properly:

# Test unauthenticated request (should fail)
curl http://localhost:8080/api/tags

# Test authenticated request (should succeed)
curl -u username:password http://localhost:8080/api/tags

A successful response should return a list of models; failure will return a 401 Unauthorized error.


Using Caddy with Basic Auth

Caddy is another popular reverse proxy with simpler configuration:

Install Caddy

# Ubuntu/Debian
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

# macOS
brew install caddy

Generate Password Hash

caddy hash-password

After entering your password, copy the generated hash.

Configure Caddyfile

Create or edit /etc/caddy/Caddyfile:

Caddyfile
:8080 {
    basicauth {
        username $2a$14$hashed_password_here
    }

    reverse_proxy localhost:11434
}

Replace $2a$14$hashed_password_here with the password hash generated earlier.

Caddy listens on port 8080 and forwards to Ollama's default port 11434, no Ollama configuration changes needed.

Restart Caddy

sudo systemctl restart caddy

Configuring Authentication in OllaMan

Once your server-side authentication is in place, pick the matching scheme when adding or editing the server in OllaMan:

Open Server Settings

Click the Settings icon in the sidebar, then select the Servers tab.

Server Settings

Add or Edit Server

Click the "Add Server" button, or edit an existing server.

Pick an Authentication Scheme

In the server form, fill in the basics first:

  1. Server Name: Give the server an easily recognizable name
  2. Server URL: Enter the proxy or gateway address (e.g. http://192.168.1.100:8080)

Then, in the Authentication section, use the segmented control to pick the scheme that matches your server:

None

The default. No credentials are sent. Suitable for local or trusted intranet environments.

Basic

Matches Nginx/Caddy Basic Auth on the server side:

  • Username: the auth username
  • Password: the auth password (click the 👁 icon on the right to reveal it)

Backward compatibility: when upgrading from an older version, any existing username / password is automatically recognized as Basic auth — no manual migration needed.

Bearer

Matches API gateways or Cloudflare Tunnel setups that require a Bearer token:

  • Token: paste your access token (click the 👁 icon to reveal it)
  • If you accidentally include a Bearer prefix, it's stripped automatically so you won't end up with Bearer Bearer xxx

Custom

Matches gateways like Cloudflare Access that don't use the Authorization header:

  • Click "Add Header" to add a key/value pair
  • Typical example: Cloudflare Access service tokens CF-Access-Client-Id and CF-Access-Client-Secret
  • Multiple header pairs can be added at once

Values are preserved when switching schemes: toggling between Basic / Bearer / Custom keeps each scheme's already-filled values so you can compare. On save, only the fields relevant to the active scheme are kept — credentials for other schemes are stripped so no unused secrets linger in config.json.

Test Connection

Click the "Test Connection" button.

If the authentication information is correct, you'll see:

  • Connected: Green indicator
  • Server version information

If authentication fails, it will display:

  • Connection Failed: Red indicator
  • Error message (usually "401 Unauthorized")

Save Configuration

After a successful test, click the "Save" button.

In the server list, any server with authentication configured shows a purple badge identifying the scheme in use (None shows no badge). OllaMan automatically attaches the corresponding auth headers to every request, including streaming chat and model uploads.


Security Best Practices

Protect Your Server

Network Security

  • Don't expose directly: Avoid exposing Ollama directly to the public internet
  • Use VPN: Access remote servers through VPN or SSH tunnels
  • Configure firewall: Limit access to specific IP addresses only
  • Enable HTTPS: Always use HTTPS encrypted connections in production

Authentication Management

  • Strong passwords: Use passwords with 20+ characters
  • Regular rotation: Periodically change authentication credentials
  • Separate credentials: Don't share the same credentials among team members
  • Least privilege: If possible, assign different permission levels to different users

Access Control

  • Monitor logs: Regularly check access logs to detect anomalous behavior
  • Limit connections: Use IP whitelisting to restrict access sources
  • Timely cleanup: Remove user accounts that are no longer in use
  • Stay updated: Keep Ollama, Nginx/Caddy updated to the latest versions

For production environments and internet access, HTTPS configuration is strongly recommended:

Using Let's Encrypt with Nginx

# Install Certbot
sudo apt install certbot python3-certbot-nginx

# Obtain certificate and automatically configure Nginx
sudo certbot --nginx -d your-domain.com

Using Caddy (Automatic HTTPS)

Caddy automatically obtains and renews SSL certificates for your domain:

Caddyfile
your-domain.com {
    basicauth {
        username $2a$14$hashed_password_here
    }

    reverse_proxy localhost:11434
}

After restarting Caddy, it will automatically obtain and configure the SSL certificate.


Troubleshooting


Next Steps