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.

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 http://1.2.3.4 and https://1.2.3.4, 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.

share|improve this question

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

share|improve this answer
    
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 '13 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. –  Jani Karlsson Aug 12 '13 at 1:54
    
noted, but nothing changed... –  Nikita Aug 12 '13 at 2:34
    
@JaniKarlsson Your link says that it supports SNI. –  VBart Aug 12 '13 at 12:20

Your Answer

 
discard

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

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