V
V
Valentine2014-02-01 08:35:21
Nginx
Valentine, 2014-02-01 08:35:21

How to make HTTP Basic Auth for one virtual host in Nginx SSL?

Can you tell me how to make https in nginx only for one virtual host?
Now I have the following:

http {
 ssl_session_cache   shared:SSL:10m;
   server {
      server_name srv1.example.com
      listen 80;
      listen 443 ssl;
   }
   server {
      server_name srv2.example.com
      listen 80;
      location / {
         auth_basic           "Test closed site";
         auth_basic_user_file conf.d/htpasswd;
      }
   }
}

SSL works for both virtual hosts. It would be desirable, that only for the first. In addition, HTTP Basic Auth works only for HTTP, when connecting via HTTPS, no login prompts appear, the site opens immediately.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
egor_nullptr, 2014-02-01
@vvpoloskin

Read here nginx.org/en/docs/http/configuring_https_servers.h... namely, the section about SNI.

P
Pavel Zhovner, 2014-02-01
@zhovner

What do you think should happen when accessing srv2 via https?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question