Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

6 November 2026 · Practical AI builds

How do I put a simple password in front of a private web tool?

By the end of this note, anyone who opens your private tool will see a browser box asking for a username and password before the page loads. This suits a small dashboard, an internal AI helper or an admin page on your own server that only you or a few colleagues should open. It uses nginx's built-in basic authentication, so you do not need to change the tool itself.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

What you need

Step by step

  1. Install the password tool with sudo apt install apache2-utils.
  2. Create the password file and your first user. The -c creates the file, so leave it off when you add more people later, or you will wipe the file and everyone in it.
    sudo htpasswd -c /etc/nginx/.htpasswd alice
    sudo htpasswd /etc/nginx/.htpasswd bob
  3. Lock the file down so only root can write to it and nginx can read it.
    sudo chown root:www-data /etc/nginx/.htpasswd
    sudo chmod 640 /etc/nginx/.htpasswd
  4. Open the nginx site file for your tool (often in /etc/nginx/sites-available/) and find the HTTPS server block, the one that listens on 443.
  5. Add the two auth lines to the location that serves the tool. The text in quotes is just a label some browsers show in the prompt.
    server {
        listen 443 ssl;
        server_name tool.example.com;
    
        location / {
            auth_basic "Private";
            auth_basic_user_file /etc/nginx/.htpasswd;
            proxy_pass http://127.0.0.1:3000;
        }
    }
  6. Check the config for mistakes with sudo nginx -t. Fix anything it reports before going further.
  7. Reload nginx with sudo systemctl reload nginx. A reload keeps current visitors connected.
  8. Make sure the tool itself only listens on 127.0.0.1, not on a public port. If it also answers on something like example.com:3000, people can go straight past the password.
  9. To remove someone later, run sudo htpasswd -D /etc/nginx/.htpasswd bob. The change applies to new logins straight away, without a reload.

What good looks like

Open the address in a private browser window. You should get a login box before any of the tool appears. Cancel it and you should see a "401 Authorization Required" page, not your tool. Enter the right details and the tool loads as normal. Then try the tool's port directly from another machine (for example http://example.com:3000). It should not connect at all. If it does, go back to step 8.

Watch out for

Plain HTTP gives the password away. Basic authentication sends the username and password with every request, only lightly encoded, not encrypted. Over HTTPS that is fine. Over plain HTTP, anyone on the same network can read them. Also bear in mind there is no built-in lockout after wrong guesses. Use long, unique passwords, and consider a tool such as fail2ban to watch the nginx error log and block repeat offenders.

Certificate renewals. If you add the password to the plain HTTP (port 80) block as well, Let's Encrypt renewals that check over port 80 can fail. Keep the password on the HTTPS block, or add auth_basic off; inside a location /.well-known/acme-challenge/ block. Finally, this is a simple gate, not a full user system. It cannot do password resets, two-factor codes or different levels of access. If the tool holds anything sensitive about customers, think about whether you need more than this.

Questions people ask

How do I log out of basic authentication?

There is no proper logout button. Browsers remember the login until you close them, so closing the browser or using a private window is the usual way to sign out.

Is there a way to keep the tool off the internet completely?

Yes. If only you use it, you can leave it on 127.0.0.1 with no public address and reach it through an SSH tunnel instead, as explained in How do I tunnel a remote app to my laptop with SSH?

With one password file and two lines of nginx config, your private tool now asks for a login before it shows anything, and you can add or remove people with a single command. Keep it behind HTTPS, keep the tool on 127.0.0.1, and it does the job well for a small team. You can get the same kind of VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related AI builds: How do I add a search box that understands meaning to my own documents? · How do I keep private data out of AI tools? · How do I make AI answers show where they came from? · All daily notes