Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Good evening. How i can protect some URL by password(auth_base)? When i try write

location ^~ /test/ {
auth_basic "admin login";
auth_basic_user_file /etc/nginx/httpd.passwd;
   location ~ \.php$ {
      include fastcgi.conf;
      fastcgi_pass наш-сокет;
     }
}

nothing happens, but when in location real directory - all work fine. This is my default config:

server {
listen 80;
server_name ~^(www\.)?test(?\d+)(?-alias)?.srv23.megaserver.umisoft.ru;
root /home/testfarm/test$id/htdocs/;

client_max_body_size 10m;

rewrite_log on;
access_log /home/testfarm/nginx_access.log;
error_log /home/testfarm/nginx_error.log debug;

location ~* \/\.ht {
deny all;
}

location ~* ^\/(classes|errors\/logs|sys\-temp|cache|xmldb|static|packages) {
deny all;
}

location ~* (\/for_del_connector\.php|\.ini|\.conf)$ {
deny all;
}

location ~* ^(\/files\/|\/images\/) {
try_files $uri =404;
}

location ~* ^\/images\/autothumbs\/ {
try_files $uri @autothumbs =404;
}

location @autothumbs {
rewrite ^\/images\/autothumbs\/(.*)$ /autothumbs.php?img=$1$query_string last;
}

location @clean_url {
rewrite ^/(.*)$ /index.php?path=$1 last;
}

location @dynamic {
try_files $uri @clean_url;
}

location / {
rewrite ^\/robots\.txt /sbots.php?path=$1 last;
rewrite ^\/sitemap\.xml /sitemap.php last;
rewrite ^\/\~\/([0-9]+)$ /tinyurl.php?id=$1 last;
rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last;
rewrite ^\/(.*)\.xml$ /index.php?xmlMode=force&path=$1 last;
rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1 last;
if ($cookie_umicms_session) {
error_page 412 = @dynamic;
return 412;
}
if ($request_method = 'POST') {
error_page 412 = @dynamic;
return 412;
}
try_files /sys-temp/static-cache/test$id$alias.srv23.megaserver.umisoft.ru/$uri/index.html @dynamic;
}

location ~* \.js$ {
rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last;
try_files $uri =404;
}

location ~* \.(ico|jpg|jpeg|png|gif|swf|css)$ {
try_files $uri =404;
access_log off;
expires 1m;
}

location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 3600;
include fastcgi_params;
}
}
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.