D
D
Dmitry Kulikov2015-09-10 17:19:34
Nginx
Dmitry Kulikov, 2015-09-10 17:19:34

How to configure auth_basic nginx correctly?

I configure nginx
Here is a piece of the config

location / {
                 try_files $uri $uri/ /index.php?$query_string;
        }



        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
         }
location /dp/ {
                auth_basic           "closed site";
                auth_basic_user_file  /home/local/html/.htpasswd;
        }

At the same time, auth_basic works on localhost/dp/ but not on localhost/dp/index.php, what can you advise in this situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2015-09-10
@dmitryi_k

location / {
                 try_files $uri $uri/ /index.php?$query_string;
        }



        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
         }
location /dp/ {
                auth_basic           "closed site";
                auth_basic_user_file  /home/local/html/.htpasswd;
       location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
         }
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question