Toolsky

Free Online Tools & Utilities for Every Task.

HTTP-auth Generator

Generate .htpasswd and server configuration rules for Apache and Nginx HTTP Authentication.

Manage Accounts
Protected Directories
Use absolute system paths for AuthUserFile compatibility.

Some parts of a website should ask for a password before they show anything at all: a staging site a client has not approved yet, an admin directory, a private download area. HTTP Basic authentication is the server's own built-in way to add that lock, but setting it up means producing a correctly hashed password file and matching server configuration — fiddly work to do by hand. This HTTP-auth generator creates both for you: enter a username and password, and it produces the .htpasswd entry plus the configuration rules for Apache and Nginx.

What HTTP Authentication Is and Where It Fits

HTTP authentication is handled by the web server itself, before any of your site's code runs. When a visitor requests a protected address, the server answers with a 401 response and the browser shows a small sign-in prompt. Only after the visitor enters credentials that match the password file does the server serve the page. Because the check lives in the server, it protects everything behind the address — pages, images, files — without the application needing any login system of its own. That makes it ideal as a temporary or additional barrier: hiding a site under construction from search engines and casual visitors, restricting a development or staging copy, gating an internal tool on a company network, or adding a second layer in front of an admin area that already has its own login. It is a perimeter lock, best understood as exactly that: a way to keep the general public out of places they were never invited.

What the Generator Produces

  • .htpasswd entries: a ready-to-paste line pairing your username with a properly hashed version of your password — never the password in plain text.
  • Strong password hashing: the password is transformed using a recognised one-way hashing scheme of the kind Apache and Nginx expect, so the file on the server cannot be read back into the original password.
  • Apache configuration: the .htaccess or virtual-host block that tells Apache which directory to protect and where the password file lives.
  • Nginx configuration: the equivalent auth_basic directives for an Nginx server block, since Nginx uses the same password-file format with its own configuration style.
  • A matched pair: the file entry and the configuration are generated together, so the two halves of the setup agree with each other and can be installed in one sitting.

Once the area is protected, related hardening steps are worth a look: redirect rules for old addresses belong in the same .htaccess file you will be editing, and the htaccess redirect generator helps write those safely, while the password generator can supply a strong credential worth hashing in the first place.

How to Set Up Password Protection

  1. Choose the username and a strong, unique password for the protected area.
  2. Enter them in the generator and produce your .htpasswd entry and the configuration for your server type.
  3. Create the password file on your server — by convention named .htpasswd — and paste the generated line into it.
  4. Place that file outside the publicly served web root wherever your hosting allows, so it can never be downloaded directly.
  5. Add the generated configuration to your site's .htaccess (Apache) or server block (Nginx), adjusting the file path to where you actually placed the password file.
  6. Restart or reload the server if your setup requires it (Nginx does; Apache .htaccess changes usually apply immediately).
  7. Visit the protected address in a private browser window and confirm a prompt appears and your credentials let you in.

A Typical Job: Locking a Staging Site

A web designer builds a replacement site for a bakery at staging.example.com. The client needs to review it, the existing customers must not stumble onto half-written prices, and Google must not index the draft. She generates credentials for the review team, installs the password file and four lines of configuration, and the staging address now answers every visit with a sign-in prompt. The client gets the username and password by phone, reviews the site for a week, and launch day is simply removing the configuration block. No plugin, no user database, no changes to the site itself — the lock was entirely at the server door, which is precisely where a temporary barrier belongs.

Honest Limits and Safety Notes

Use it only on servers you own or administer. This generator is for protecting your own sites and authorised projects — the same standing rule as any security tool. Basic authentication demands HTTPS. Credentials are sent with every request, encoded but not encrypted; on a plain HTTP connection they can be intercepted, so never protect an area on a site without a working TLS certificate. It is a barrier, not a vault. Basic auth has no protection against repeated guessing at the server level unless you add rate limiting or IP restrictions, so pair it with a genuinely strong password — hashed with a modern algorithm such as bcrypt, which the bcrypt generator explains in more depth — and never reuse an important password for it. Mind the password file's location. If the .htpasswd file sits inside the web root and your server is misconfigured, it could be downloadable; outside the root is the safe pattern. And note that once a browser accepts credentials, it keeps sending them for the session — there is no tidy "log out" button, which is another reason this suits temporary and restricted areas rather than public membership systems.

Frequently Asked Questions About HTTP Authentication

What exactly is a .htpasswd file?

It is a plain text file the server consults during HTTP authentication. Each line holds a username and the hashed form of that user's password, separated by a colon. The server hashes what a visitor types and compares the results.

Why is the password hashed instead of stored directly?

So that anyone who somehow obtains the file cannot read the actual passwords from it. Hashing is one-way: the server can verify a login attempt by hashing it and comparing, but the stored value cannot be turned back into the password.

Is HTTP Basic authentication secure?

Over HTTPS, with a strong password and a modern hash, it is a reasonable barrier for staging sites, internal tools and extra admin protection. Over plain HTTP it should not be used, because the credentials cross the network without encryption.

What is the difference between the Apache and Nginx setups?

Both read the same style of password file, but the surrounding configuration differs: Apache typically uses directives in .htaccess or the virtual host, while Nginx uses auth_basic and auth_basic_user_file lines inside the server or location block. The generator produces the matching form for each.

Why do I keep getting the login prompt after entering the password?

Usually a mismatch: the configuration points at a different password file than the one you edited, the username was typed differently, or the server cannot read the file because of its permissions. Check the path in the configuration first — it is the most common culprit.

Can I protect just one directory or file instead of the whole site?

Yes. On Apache, placing the configuration in a directory's own .htaccess protects that directory; Nginx location blocks can target a specific path. The rest of the site stays public.

What happens if I forget the password?

There is no recovery email for a password file — you simply generate a fresh entry with a new password, replace the old line in the file, and the new credential works immediately. Server access is the recovery mechanism.

Can search engines still index a protected area?

No. Crawlers receive the same 401 response as any other unauthenticated visitor, so protected content is not indexed — which is one reason this technique is popular for staging sites.

A Simple Lock, Fitted in Minutes

Not every page deserves an audience. When a corner of your server needs to stay private — for a week of client review or for the lifetime of an internal tool — a generated password file and a few lines of configuration put a proper lock on the door without building a login system to do it.