Skip to content

block access by ip #2264

Answered by elclay7
elclay7 asked this question in Q&A
Jun 27, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Thanks for your answer, it guides me a lot.
Yes, I need both conditions to be met, the way to achieve it was the following
The /etc/nginx/vhost.d/site.com file should only have this:

     allow 1.1.0.0/16;
     allow 2.2.0.0/14;
     allow 3.3.0.0/24;
     deny all;

And to request a password, just create it with htpasswd -c /etc/nginx/htpasswd/site.com, it is not necessary to add conf lines in the previous conf file (vhost.d/site.com), it is important that the names of the configuration files are named like the site (site.com) and not end in .conf
With this the configuration will be added to the main file that is regenerated every time nginx is restarted /etc/nginx/conf.d/default.conf an…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elclay7
Comment options

Answer selected by elclay7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants