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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To remove Nginx HTTP Basic Authentication, remove the auth_basic and auth_basic_user_file directives from the configuration block that applies to the protected requests. Test the configuration with nginx -t, then reload Nginx with nginx -s reload or your service manager. If only one directory or URL should become public while the rest remains protected, keep the parent rule and add auth_basic off; to that child location block instead.

The password file does not have to be deleted. Nginx stops reading it when no effective auth_basic rule uses it, so remove the file only after checking that no other virtual host or location references it.

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

What controls htpasswd protection in Nginx?

Nginx’s Basic Authentication module uses two directives together:

Directive Purpose Typical value
auth_basic Enables authentication and defines the realm text shown in the browser login prompt. auth_basic "Restricted site";
auth_basic_user_file Specifies the path to the file containing usernames and password hashes in htpasswd format. auth_basic_user_file /etc/nginx/.htpasswd;

The directives can appear in the http, server, location, or limit_except contexts. A rule at a broader level can therefore affect many requests. For example, a server-level rule is inherited by locations in that server unless a location overrides it.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Deleting only the password-file directive is not a reliable way to disable the login prompt. Leave auth_basic active and Nginx may still attempt authentication, producing configuration errors or an unusable protected endpoint. Remove both directives at the level where they are defined, or explicitly turn authentication off in the location that should be public.

Choose between deleting authentication and overriding it

Goal Configuration change Result
Make an entire server or site public Delete both directives from the applicable http, server, or site-wide location block. Requests at that configuration level no longer use htpasswd authentication, provided no parent block still enables it.
Make one path public while retaining protection elsewhere Add auth_basic off; inside the public child location. The child location cancels the inherited authentication rule; other locations continue to require credentials.
Remove a no-longer-used credential file Delete the htpasswd file only after confirming there are no remaining references. Frees the file, but does not itself change Nginx’s configuration or authentication behavior.

Use deletion when the site should no longer have Basic Authentication at all. Use auth_basic off; when the protected parent is intentional and you are creating an exception such as a public health check, static asset directory, or documentation path.

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

Step 1: Find every effective authentication rule

Before editing, identify where the directives are declared and which configuration files Nginx actually includes. On a conventional Linux installation, search the main configuration tree:

sudo grep -rn "auth_basic" /etc/nginx/

Search for the file directive as well, because it may be on a different line or included file:

sudo grep -rn "auth_basic_user_file" /etc/nginx/

Common locations include /etc/nginx/nginx.conf, files under /etc/nginx/conf.d/, and enabled-site links under /etc/nginx/sites-enabled/. The exact layout depends on the operating system and how Nginx was installed.

Read the surrounding block rather than changing the first matching line blindly. A match in http {} can protect every server, a match in server {} can protect one virtual host, and a match in location {} affects only that location. Also inspect files included by include statements; an apparently removed rule can remain active if another included file defines it.

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

Step 2: Remove protection from an entire site

Suppose a virtual host contains this configuration:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
server {
    listen 443 ssl;
    server_name example.com;

    auth_basic "Staging";
    auth_basic_user_file /etc/nginx/.htpasswd;

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

Delete both authentication lines, leaving the rest of the server block unchanged:

server {
    listen 443 ssl;
    server_name example.com;

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

If the directives were declared in http {} or another parent block, remove them there only if every site using that parent should become public. If one server still needs protection, move the rule to that server’s own block rather than deleting a shared setting.

Do not assume that removing a location-level rule makes the location public. If auth_basic is enabled in the enclosing server or http block, the location can inherit it after its local lines are deleted. Trace the configuration hierarchy and remove the rule at its source, or use auth_basic off; in the location that must be open.

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

Step 3: Make only one directory or URL public

For a protected site with a public subpath, keep the parent authentication rule and override it in the child location. For example:

server {
    listen 443 ssl;
    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;
    }
}

Requests matching /public/ no longer receive the inherited Basic Authentication challenge, while requests handled by the other locations remain protected. The special value off cancels an auth_basic directive inherited from a previous configuration level.

Place the override in the location that actually handles the request. Nginx location matching can select a more specific prefix, regular-expression location, or exact match than the one you edited. If the response is still a login prompt, inspect all competing locations and confirm which block serves the URL.

You can use the same pattern for a single endpoint:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
location = /healthz {
    auth_basic off;
    default_type text/plain;
    return 200 "okn";
}

Keep this exception narrowly scoped. A broad location / with auth_basic off; would expose the entire site and defeat the purpose of the parent rule.

Step 4: Test the configuration before reloading

Run the configuration test as the account that has permission to read the Nginx configuration and certificates:

sudo nginx -t

A successful test reports that the syntax is valid and the test is successful. If it fails, Nginx will identify a file and line number. Fix that error before attempting a reload; a failed test does not apply your edit.

Frequent test failures

  • Missing semicolon: Every directive, including auth_basic off;, needs a trailing semicolon.
  • Editing the wrong file: The active configuration may be an included file or a distribution-specific path. Follow the include chain from the main configuration.
  • Bad htpasswd path: If another protected location still references a file that was moved or deleted, the test can fail even though your edited site is public.
  • Permission or certificate errors: Running the test without sufficient privileges can prevent Nginx from reading files required by the complete configuration.

Do not skip the test merely because the edited lines look simple. Nginx loads the full configuration tree, so an unrelated syntax error can prevent a reload.

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

Step 5: Reload Nginx and verify without credentials

After nginx -t succeeds, reload the running master process:

sudo nginx -s reload

On systems managed by systemd, the equivalent is commonly:

sudo systemctl reload nginx

A reload applies the new configuration without intentionally stopping existing worker processes. Use the service-manager command appropriate to your installation if Nginx is supervised by another platform.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Test the exact URL that was previously protected, without supplying a username or password:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -i https://example.com/protected/

For a successfully opened resource, expect the application’s normal response rather than an authentication challenge. A formerly protected endpoint commonly returned 401 Unauthorized with a WWW-Authenticate header; those indicators should disappear when the request is handled by a location with authentication disabled. Check both the public path and a path that should remain protected when you used an override.

Use the same hostname, scheme, and path that users access. Testing an HTTP redirect while the rule is on HTTPS, or testing a different virtual host resolved by the same IP address, can produce a misleading result.

What to do with the htpasswd file

The htpasswd file is only a credential store. It is not what turns authentication on. Once no effective auth_basic directive points to it, Nginx no longer uses that file for requests served by those blocks.

Keeping the file is often the safest first choice. It allows a quick rollback and avoids breaking another server block that still references the same path. If you decide to remove it:

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.
  1. Search all Nginx configuration files for the exact path.
  2. Check other virtual hosts, included snippets, deployment templates, and automation that might recreate or reference it.
  3. Confirm that nginx -t succeeds after the deletion.
  4. Reload Nginx and verify every site that previously used the file.
  5. Remove backups or copies according to your credential-retention policy.
sudo rm /etc/nginx/.htpasswd

Deleting a credential file is irreversible unless you have a secure backup. It also does not revoke credentials in an application, identity provider, or upstream service; it affects only Nginx Basic Authentication that used that file.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Configuration-scope examples

Where the rule is defined Typical reach How to open one child path
http {} Potentially every server and location inheriting the setting. Add auth_basic off; in the specific server or location, or remove the shared rule only after auditing all sites.
server {} Requests handled by that virtual host, unless a child location overrides it. Add auth_basic off; to the public child location.
location {} Requests matching that location. Remove the two directives from that location; check parent blocks for inherited rules.
limit_except {} Only the methods covered by the limit_except block. Review method-specific behavior separately; changing a normal location does not automatically remove a rule scoped to limited methods.

Scope is determined by the complete Nginx configuration, not by the directory name of the htpasswd file. A file under a site directory can still be referenced by a server-wide snippet, and a server-level rule can protect a URL whose content is stored elsewhere.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Troubleshooting when the login prompt remains

The old configuration is still running

Confirm that the reload command succeeded and that you edited the configuration used by the running Nginx process. Run nginx -t again, inspect the reload output, and check the service status through your process manager.

A parent block still enables authentication

Search for every auth_basic occurrence, including included snippets. If a parent rule remains, either remove both directives at that parent level or add auth_basic off; to the exact child location that should be public.

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

The request matches another location

Location precedence can route the request to a block other than the one you edited. Compare the requested path with exact, prefix, and regular-expression locations. Add the override to the selected block, then retest the precise URL.

A proxy or application is challenging separately

Nginx Basic Authentication is only one possible source of a 401 response. An upstream application, API gateway, CDN, or another reverse proxy can issue its own challenge. Inspect response headers and test the origin path where appropriate before concluding that auth_basic is still active.

Cached responses obscure the change

Use a fresh request with curl and inspect headers. Browser prompts and cached redirects can persist visually even after the server configuration changes; an incognito request or a different client helps separate browser state from server behavior.

Security checks before making a site public

Removing Basic Authentication exposes the location to anyone who can reach it. Before reloading, check what the location serves and whether another access control is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Confirm that no administrative panel, staging data, backups, source maps, or private documents are under the newly public path.
  • Check whether the application itself performs login and authorization. Nginx authentication may have been an additional layer rather than the only control.
  • Review access logs after the change for unexpected traffic and sensitive paths.
  • Use HTTPS for public requests when credentials, session cookies, or personal data are involved.
  • Keep a copy of the previous configuration so you can restore the protection quickly.

For a temporary opening, record the intended scope and set a reminder to remove the exception. A narrowly targeted location override is easier to audit than changing a shared http-level rule.

Quick command checklist

  1. Find the rules: sudo grep -rn "auth_basic" /etc/nginx/ and sudo grep -rn "auth_basic_user_file" /etc/nginx/.
  2. Decide whether to delete both directives or add auth_basic off; to one child location.
  3. Save the configuration file.
  4. Validate it: sudo nginx -t.
  5. Reload it: sudo nginx -s reload or sudo systemctl reload nginx.
  6. Verify with an unauthenticated curl -i request to the exact URL.
  7. Only then consider deleting an unused htpasswd file.

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.