nginx how to run first site as open , and second as basic auth .

2014-12-26 Thread Tuyosi Takesima
hi,all .

i use name based virtual host (=server block).
i want to run first site as open  and second site as ristricted (basic
auth),
but it is hard to do and there is little information on internet about this
.


it is easy to run only name based virtualhost (=server block) .
nginx.conf is next .

worker_processes  1;
worker_rlimit_nofile 1024;
events {
worker_connections  800;
}


http {
include   mime.types;
default_type  application/octet-stream;
index index.html index.htm;
keepalive_timeout  65;
server_tokens off;

   server {
listen   80;
listen   [::]:80;
server_name  a.mydns.jp;   --- 1st site
root /var/www/htdocs/d1;
}

   server {
listen   80;
listen   [::]:80;
server_name  s.sun.ddns.vc; --- 2nd site
root /var/www/htdocs/d2;
  }
}
---

give me some hints .



Re: nginx how to run first site as open , and second as basic auth .

2014-12-26 Thread Alexandr Borisenko
 i want to run first site as open  and second site as ristricted (basic
auth),
 but it is hard to do and there is little information on internet about
this

Just add
auth_basic Test site;
auth_basic_user_file  .htpasswd;
to second server { ... } block.