0 votes
140 views
by Talented

Hi,

I want to password protect an entire staging site, so httpauth -wp-admin=on isn't enough. Based on a few answers on similar topics, my understanding is that in order to achieve that, I will have to edit the nginx config files under /etc/nginx/common

If I do so, though, wouldn't my changes get lost after a Webinoly update? At least that's what the warnings on those files suggest.

So, I was wondering if there is a better way to do it. I tried creating a custom-nginx.conf file on the root on my site and added the following rule:

location = / {
        include common/acl.conf;
}

It will password protect the Homepage, but not the internal pages. If i remove = and keep only location /, nginx -t throws an error saying that location / is a duplicate.

If I do location ~ / It will password protect everything, but after signing in, only the home page works. The rest of the pages will throw a server error.

Thanks in advance for any suggestions

George

1 Answer

+2 votes
by Expert
selected by
 
Best answer

Just put the "include acl" line in /etc/nginx/sites-available/domain.com, in the server block and before the first include in that block, in this case you don't need the location directive, then restart the Nginx service.

And as I mentioned several times before here, this feature will be included in the next major release (v1.9.0).

by Talented
Thank you for the instant response.

I think that I tried that too on my first efforts but it didn't work at first. I must have missed something (maybe it was the order, because I think that I put it right before the last one).

I followed your suggestion now and it worked perfectly.

Thanks again for the great product and support!
by Rookie
edited by

Had the same need and was looking for the answer here. My whole dev site is now password protected regardless of the page. Thanks for the hint, it works like a charm! Looking forward to the next major release!

Just in case here are the terminal commands I used:

1. Opened the corresponding site file

sudo nano "/etc/nginx/sites-available/dev.mysite.com"

2. Inserted the include common/acl.conf; line and made it the first of the includes/

3. Checked the Nginx configuration

sudo nginx -t

4. After successful check reloaded Nginx to keep FastCGI cache intact for the production site

sudo service nginx reload
by Talented

BTW, I hope that the new release will give us the option to easily set a different username/password for each site. For the time being I handled it by creating a new htpasswd file and added the following on /etc/nginx/sites-available of the respective site's config file:

 satisfy any;
 auth_basic "Restricted Area";
 auth_basic_user_file .htpasswd-gsarig;
by Rookie
Yes, that would be a useful feature. Thanks for sharing your workaround.
by Expert
You are lucky, today I will release v1.9.0 and actually, it includes the option to have specific users per site. In general, you will see a lot of improvements in the HTTP Auth area.

Your feedback will be very appreciated, hope you can test these new features.
by Talented
Great! I was expecting this and will definitely try it.

BTW, I believe that it would be nice if there was an online roadmap. The other time, out of curiosity, I was searching for the features that will be included on 1.9.0 as well as those that will be on the December's release, but I couldn't find anything.
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

If you have a question about Webinoly, please ask in English or Spanish.

To report a bug, please ask a question here with the bug tag.

Donations

Webinoly Support Paypal Donations Webinoly Support Bitcoin Donations

Your regular donations is what keep this project moving forward. If you like Webinoly, buy me a coffee or a beer to show support.

Affiliate Links

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...