DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Remove htpasswd Password Protection in Nginx

Learn how Nginx’s auth_basic directives work, how to remove protection globally or open one location with auth_basic off, and how to test, reload, verify, and safely retire the htpasswd file.
WorldNginx Length9 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To remove HTTP Basic Authentication in Nginx, remove both auth_basic and auth_basic_user_file from the configuration block that enables them, test the configuration, and reload Nginx. If only one directory should be public while the rest of the site remains protected, keep the parent rule and add auth_basic off; to that directory’s location block. Deleting the htpasswd file is optional and should be done only after confirming that no remaining configuration uses it.

Which Nginx directives create htpasswd protection?

Nginx’s HTTP Basic Authentication module uses two directives:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • auth_basic enables authentication and sets the realm name shown by the browser’s login prompt.
  • auth_basic_user_file tells Nginx which htpasswd-format file contains usernames and password hashes.

A typical protected server looks like this:

server {
    listen 80;
    server_name example.com;

    auth_basic "Members only";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location / {
        try_files $uri $uri/ =404;
    }
}

The directives can be placed in the http, server, location, or limit_except context. Their position determines which requests inherit the protection. Removing only the password file does not disable the rule cleanly: Nginx may still try to read the configured path and fail, while leaving auth_basic enabled continues to advertise a protected area. Remove or override the authentication directives themselves.

Choose between deleting the rule and overriding it

Goal Change Effect
Make an entire protected scope public Delete auth_basic and auth_basic_user_file from the block where they are defined. Requests handled by that block no longer use Basic Authentication, unless another more-specific rule enables it.
Keep the site protected but publish one path Add auth_basic off; inside the public path’s child location. The child location cancels the inherited auth_basic setting while the parent remains protected.
Retire the credential file after a configuration change Delete the htpasswd file only after searching all active configuration files for references. The file is no longer needed by Nginx, but deleting it does not itself change the loaded configuration.

Use deletion when the authentication requirement has ended for the whole scope. Use off when the exception is intentional and the parent rule should continue protecting other URLs.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Find where authentication is enabled

Nginx commonly loads a main file plus files from an include directory, so the directive may not be in the file you first open. Search the complete configuration tree before editing:

sudo grep -rn --include='*.conf' "auth_basic" /etc/nginx/

On systems that keep configuration elsewhere, substitute the directory used by your Nginx installation. Inspect every match and note whether it is in an http, server, location, or limit_except block. Also check included snippets: a server can appear unprotected in its main file while inheriting authentication from a snippet included at the http level.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before changing production configuration, make a backup of the file or snippet you will edit. Record the active configuration path if your service manager uses a nonstandard layout. Do not delete the htpasswd file at this stage; first establish that no block still references it.

Remove Basic Authentication from the whole scope

Follow these steps when the site, virtual host, or directory should no longer require a username and password.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
  1. Open the file containing the matching directives. For example, edit the server or included snippet identified by the search command.
  2. Remove both directives from the block where they are set. Delete lines such as:
    auth_basic "Members only";
    auth_basic_user_file /etc/nginx/.htpasswd;
  3. Check for another inherited or more-specific rule. Search again and inspect any parent http or server block, as well as nested locations. Removing a child rule cannot cancel a parent rule unless the child explicitly uses auth_basic off;.
  4. Save the file. The running worker processes continue using the old configuration until a successful reload.
  5. Validate the syntax. Run:
    sudo nginx -t

    The command must report that the configuration test is successful. If it reports an error, fix that error before reloading; the old configuration remains safer than a failed change.

  6. Reload Nginx. Use the Nginx signal command:
    sudo nginx -s reload

    Use your service manager’s reload operation instead if that is how the installation is administered.

  7. Test without credentials. Send a request that does not include an Authorization header:
    curl -i http://example.com/

    Confirm that the response matches the application’s expected public response rather than a 401 Unauthorized challenge.

A reload applies the new configuration without requiring a full stop and start. If a proxy, cache, or load balancer sits in front of Nginx, test the public hostname as well as the local server so that you verify the path users actually reach.

Open one directory while protecting the rest

When authentication is configured at the server or http level, a child location inherits it. The special value off cancels an inherited auth_basic directive. This is the appropriate pattern for a public download area, health endpoint, game server status page, or other deliberately open path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 80;
    server_name example.com;

    auth_basic "Members only";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location / {
        try_files $uri $uri/ =404;
    }

    location /public/ {
        auth_basic off;
        try_files $uri $uri/ =404;
    }
}

With this arrangement, requests under /public/ do not receive the inherited Basic Authentication challenge, while requests handled by / continue to require credentials. You do not need to repeat auth_basic_user_file in the public location, and you normally do not need to remove the file directive from the parent. Because auth_basic off; disables the inherited authentication check, the inherited file path is not used for that location.

Place the exception in the location that actually handles the request. Nginx location matching can select a different block than expected, especially when exact, prefix, or regular-expression locations coexist. If the URL still prompts, inspect the effective location hierarchy and all included snippets rather than adding multiple off directives at random.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Understand scope and inheritance

Configuration context Typical use What an edit affects
http A global default for configured virtual hosts. All descendant servers and locations that do not override or cancel it.
server Protection for one virtual host or listening configuration. Locations inside that server unless a child changes the setting.
location Protection for one URL prefix, exact path, or pattern. Only requests selected by that location.
limit_except Method-specific access rules inside a location. Only the methods covered by that block.

For a complete removal, delete the directives at the level that introduced them and verify that no ancestor still supplies auth_basic. For a narrow exemption, leave the ancestor intact and put auth_basic off; in the selected child location. The file directive identifies credentials; it does not independently turn authentication on.

Validate, reload, and verify the result

Read the configuration-test output

Run nginx -t with the same privileges and configuration path used by the service. A successful test checks that Nginx can parse the edited configuration and load referenced files. A failure commonly points to a missing semicolon, an unmatched brace, an invalid path, or an included file that was overlooked. Do not reload until the test succeeds.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reload only after a successful test

sudo nginx -s reload asks the running master process to reread the configuration and start workers with the new settings. If your platform uses a service manager, its equivalent reload action is acceptable. A reload is distinct from editing the file: saving alone does not change the behavior of already running workers.

Make an unauthenticated request

Use a request without credentials so the result is unambiguous:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
curl -i http://example.com/public/

For an HTTPS site, test the real HTTPS URL. A public response might be a normal application status, a redirect, or a deliberate application-level error; the important distinction is that Nginx should not issue a Basic Authentication challenge for the path you opened. A protected path should continue to challenge if you used the override pattern.

Check more than one URL

  • Test the exact public path, including a trailing slash if the application treats it differently.
  • Test a path that should remain protected when using a child-location exception.
  • Test through the public hostname if a reverse proxy or load balancer is present.
  • Repeat the test after deployment to each Nginx instance in a cluster; changing one server does not edit the others.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to do with the htpasswd file

The htpasswd file is only the credential source named by auth_basic_user_file. Once no active authentication rule references it, Nginx no longer needs it for Basic Authentication. Keeping it is harmless from Nginx’s point of view and can make rollback easier; deleting it reduces the number of sensitive files left on disk.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you choose to delete it, first search all configuration files again:

sudo grep -rn --include='*.conf' ".htpasswd|auth_basic_user_file" /etc/nginx/

Confirm that no server, location, or included snippet still points to the file. Then remove it with the permissions appropriate for your system and retain the configuration backup only if it is stored securely. Deleting the file before removing or overriding the directives can turn a working site into a configuration or authentication failure.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Troubleshoot a prompt that will not go away

The browser still shows a login dialog

  • Run the recursive search again. A second auth_basic directive may be present in an included file or another virtual host.
  • Check whether the request is reaching a different Nginx instance, container, or load-balancer backend than the one you edited.
  • Confirm that nginx -t succeeded and that a reload was actually issued after the edit.
  • Inspect the selected location. A more-specific location may handle the request and still inherit or define authentication.
  • Use a fresh command-line request. A browser can cache credentials and automatically resend them, which can hide whether the server is still challenging.

The configuration test fails after removing the lines

Read the file name and line number in the error, then repair the syntax or path it identifies. Removing two directives can expose a surrounding brace or include mistake that was previously unnoticed, but do not infer that the htpasswd file itself must be restored. Re-run sudo nginx -t until the complete configuration validates.

The public path returns 401

A 401 Unauthorized response means that the request is still being challenged by the configuration that handled it, or by another proxy in front of Nginx. Verify the exact URL, inspect parent and child blocks, and ensure auth_basic off; is inside the location selected for that URL. If another proxy performs authentication, changing Nginx’s module settings will not remove that separate challenge.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Removing the file caused errors

Restore the file or restore the previous configuration while diagnosing the references. Remove auth_basic_user_file and disable or delete auth_basic first, validate, reload, and only then decide whether the credential file should be deleted.

Security checks after disabling protection

Removing Basic Authentication changes who can reach the selected requests; it does not add a replacement access control. Before making a previously protected path public, confirm that the application itself enforces any required permissions and that the path does not expose administrative controls, private files, debug output, or credentials.

  • Review the exact URL prefix covered by the change, including aliases and alternate locations.
  • Check whether directory listings, backups, logs, or configuration files are reachable beneath that prefix.
  • Confirm that write, upload, delete, and administrative operations still have application-level authorization.
  • Record the change so another administrator does not later re-enable authentication by restoring an old snippet or delete a file that a different virtual host still needs.

If the requirement is temporary, an explicit child-location override is easier to reverse than deleting the parent rule and credential reference. If the requirement is permanent for the whole virtual host, deleting both directives and then removing an unused credential file leaves a clearer configuration.

Complete before-and-after examples

Remove protection from a virtual host

Before:

server {
    server_name example.com;
    auth_basic "Staging";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location / {
        proxy_pass http://app;
    }
}

After removing both directives:

server {
    server_name example.com;

    location / {
        proxy_pass http://app;
    }
}

Test and reload this configuration before checking the site without an Authorization header.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep protection everywhere except one path

server {
    server_name example.com;
    auth_basic "Staging";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location / {
        proxy_pass http://app;
    }

    location = /health {
        auth_basic off;
        proxy_pass http://app;
    }
}

Here, only the exact /health location is exempt. A request to another path remains covered by the server-level rule. Choose a prefix such as location /public/ instead when all descendants of that path should be public.

Operational checklist

  • Locate every auth_basic and auth_basic_user_file reference.
  • Decide whether the change applies to the whole scope or only one child location.
  • Delete both directives for complete removal, or add auth_basic off; for a deliberate exception.
  • Run sudo nginx -t and resolve every error.
  • Reload with sudo nginx -s reload or the service manager’s reload command.
  • Verify with an unauthenticated request and test a path that should remain protected.
  • Delete the htpasswd file only after confirming that no active configuration references it.
  • Review the newly public endpoint for application-level authorization and accidental data exposure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.