I
I
iandriyanov2012-07-31 10:26:37
Nginx
iandriyanov, 2012-07-31 10:26:37

Nginx asks for authorization, again?

server {
                listen *:80;
                server_name     site.local;

                satisfy  any;
                allow 127.0.0.0/16;
                allow 192.168.140.0/24;
                allow 192.168.142.0/24;
                allow 192.168.144.0/24;
                
                auth_basic              "site.local";
                auth_basic_user_file    /www/passw;

Here is such a config in location / {} - all one asks to log in while being naturally in the specified network. CHADNT?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
Ilya_Drey, 2012-07-31
@iandriyanov

satisfy must be specified at the end, it is this command that will send everyone else to basic auth.
Working option:

server {
  listen *:80;
  server_name     site.local;

  auth_basic              "site.local";
  auth_basic_user_file    /www/passw;

  allow 127.0.0.0/16;
  allow 192.168.140.0/24;
  allow 192.168.142.0/24;
  allow 192.168.144.0/24;
  deny all;
   
  satisfy  any;
}

M
Maxim, 2012-07-31
@maxout

in order of delirium: try to add the implied deny all line; after your allowed list

R
Ramzeska, 2012-07-31
@Ramzeska

Add deny all after the allow directives. And then in fact http_access does not work

I
Ilya_Drey, 2012-07-31
@Ilya_Drey

So what is happening then? Are you sure that you are actually routed to site.local in such a way that Nginx sees the address from the above networks as source address?

S
Sergey Fedotov, 2019-07-06
@FSA

My hands did not reach to figure out why the directives do not work. Today I guessed to look into the nginx log. The bottom line is that my site from an external network is accessible through a router. As a result, all requests for a domain name from the internal network do not go directly to the internal address, but are wrapped by the router on behalf of the external IP. Those. to make it work, you need to add the line allow EXTERNAL_IP. Here is such a banal solution, it was only necessary to turn on the head :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question