I have a few websites each in its own server{} block in nginx, with their domains defined in server_name directives. One of the websites also has an https server{} block. They're all on the same IP.

How do I create server blocks that would catch the requests to and, but not any of the domains? I've tried creating variations of "default" servers, but if nginx sees a default https block, it just uses that block for all https connections, including the website that has its own https server block.

nginx 1.4.2 on Ubuntu 12.04.

Thanks for any help.

1 Answer 1


nginx vhost perference is described in: http://nginx.org/en/docs/http/request_processing.html#mixed_name_ip_based_servers

default_server settings work just fine as long as you have only one SSL website for a IP:

server {
    listen x.x.x.x:443;

nginx currently doesn't support SNI properly that would allow you to specify multiple SSL certificates for single IP address: http://nginx.org/en/docs/http/configuring_https_servers.html#compatibility

  • That doesn't work for me, sadly. As soon as I create such a server block, nginx starts using it for all my websites, including my https website, which has this valid block: server { server_name domain.com; listen 443 ssl; etc... }
    – Nikita
    Aug 12, 2013 at 1:43
  • You should always use listen in format of: listen IP:443 ssl; never use just use listen 443 ssl if you have several SSL sites. Aug 12, 2013 at 1:54
  • noted, but nothing changed...
    – Nikita
    Aug 12, 2013 at 2:34
  • @JaniKarlsson Your link says that it supports SNI.
    – VBart
    Aug 12, 2013 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.