Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 662819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:25:13+00:00 2026-05-13T23:25:13+00:00

To my knowledge Nginx can only password protect directories from within the configuration file(s).

  • 0

To my knowledge Nginx can only password protect directories from within the configuration file(s). That works nicely, but is not a real option for end-users who A) can not edit the configs and B) would break the configs if they could

Right now I am thinking about a webbased representation of the directory structure where they can point and click – rewriting the configs and re-kill-HUP-ing Nginx…
But somehow the whole idea feels like I am about to rewrite cPanel v0.0.1 😉

Anybody here had the same problem and came up with an elegant and maintainable solution?
I have full control over the server.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:25:14+00:00Added an answer on May 13, 2026 at 11:25 pm

    You don’t really want users to change the configs, do you?
    For password-protection, a htpasswd-file is sufficient, if the realm always stays the same.
    And nginx itself can check for a file existense.
    So, this is what could do the job:

      location ~ ^/([^/]*)/(.*) {
            if (-f $document_root/$1/.htpasswd) {
                    error_page 599 = @auth;
                    return 599;
            }
      }
      location @auth {
            auth_basic "Password-protected";
            auth_basic_user_file $document_root/$1/.htpasswd;
      }
    

    Works for me with nginx-0.7.65.
    0.6.x and earlier releases are probably no-go

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the knowledge to do subneting math, but I confused what device that
It's common knowledge that using System.Diagnostics.Process.Start is the way to launch a url from
I have some knowledge in C/C++ but only using the Console. I'd like to
My knowledge of xml and php is somewhat basic but have been able to
My knowledge of Lambda expressions is a bit shaky, while I can write code
My knowledge of Jquery & Javascript is limited at best, but I'm under the
My knowledge of Java is rather rusty, but I've been forced to use it
I have searched the knowledge base high and low, but nothing seems to give
My knowledge of the intel instruction set is a bit rusty. Can you tell
Unfortunately my VB knowledge is very minimum, but i need a script to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.