问题原文
原帖链接 · SandyD · CC BY-SA 3.0
If I already have a bunch of virtualhosts, how can I create a virtual host to handle requests that don't match any of the virtualhosts? (i.e. access by IP, another domain linking to IP, .etc .etc)
社区高分解答
原帖链接 · andreycpp · CC BY-SA 3.0
If you use SSL, then you need some extra plumbing for a default_server - certificate and key (that can be self-signed).
server {
server_name _;
listen 80 default_server;
listen 443 ssl default_server;
ssl_certificate <path to cert>;
ssl_certificate_key <path to key>;
return 404; # or whatever
}
Nginx will try to accept SSL connection on an IP/port-matching default_server. If such server is missing cert/key, nginx will drop the connection. It won't try other servers. So don't forget cert/key.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
