Add a Login Screen to Ollama: Step by Step
Ollama has no login of its own. This walkthrough puts a simple username and password in front of it using nginx, so you can access it remotely without leaving it wide open.
Reading is great. Tracking makes it stick. Sign up for a free Dashboard to tick off tasks and see your Security Score.
Get my free Dashboard →
Cyber Nova AI helps you prepare for Cyber Essentials. It doesn't award or certify it. Follow the steps here to get ready, then apply for certification through an accredited Cyber Essentials body when you're set.
What you will need
- Ollama already installed and running (see "Set Up Ollama Securely at Home")
- nginx installed on the same machine or network
- About 20 minutes, plus basic comfort in a terminal
Install the tools needed to create a password file
On Linux, install the Apache utilities package, which includes the tool for creating password files:
sudo apt install apache2-utilsCreate a username and password
Create a password file with your first user:
sudo htpasswd -c /etc/nginx/.htpasswd yourusernameNote: You will be prompted to type a password. Remove the -c flag if adding a second user later, it would overwrite the file.
Add the login requirement to your nginx site
In your nginx site configuration file, add these two lines inside the section that handles requests to Ollama:
auth_basic "Ollama"; auth_basic_user_file /etc/nginx/.htpasswd;Point nginx at Ollama
In the same section, forward requests to Ollama’s usual address:
proxy_pass http://127.0.0.1:11434;Restart nginx and test
Apply the change and check it works:
sudo nginx -t && sudo systemctl restart nginxNote: Visiting the address nginx serves should now ask for a username and password before reaching Ollama.
What you will have at the end
Ollama reachable through nginx with a username and password required, rather than open to anyone who finds the address.
Why a password matters here
Ollama itself has no concept of a login. Anyone who reaches it directly can use it freely. Putting a password in front of it, rather than relying on Ollama to protect itself, is the actual fix, not a setting inside Ollama.
Frequently asked questions
Do I need this if I only use Ollama on my own computer?
No, this is only needed if you want to reach Ollama from outside your home network.
Is a username and password enough on its own?
For most home use, yes, combined with HTTPS. For anything more sensitive, consider adding HTTPS via a tool like Certbot as a next step.
What if I do not use nginx?
The same principle applies with other reverse proxies like Caddy, which has its own simpler syntax for basic authentication.
Track your AI safety progress. Free.
Create a free account to tick off tasks, see your Security Score improve, and know exactly what you've done and what's still to do.
Start your free security check