Why won't my configuration route to the specific server_name when it's specified?

Part of my config:

  listen      443 ssl;
  server_name foo-bar.example.com;

  include includes/http/server/ssl.conf;

  location /

  listen 80   default_server;
  listen 162  default_server;
  listen 443  default_server;
  listen 465  default_server;
  listen 3306 default_server;
  listen 9200 default_server;

  return 444;

However, going to the domain foo-bar.example.com returns the 444 status. When I remove the last block, it works as expected.

I tried adding:

  • server_name ""
  • server_name _

...in the last block without success.

The priorities defined on this page: http://nginx.org/en/docs/http/server_names.html

  • exact name
  • longest wildcard name starting with an asterisk, e.g. “*.example.org”
  • longest wildcard name ending with an asterisk, e.g. “mail.*”
  • first matching regular expression (in order of appearance in a configuration file)

...tells me that what I do should work, imo.


When looking in the error.log, located in /var/log/nginx/, I found no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking

So adding a new block:

  listen 443 default_server;
  include includes/http/server/ssl.conf;
  return 444;

...while removing the listen 443 default_server from the former block, did the trick...


ssl_certificate     /etc/ssl/certs/crt.crt;
ssl_certificate_key /etc/ssl/private/key.key;
  • @Drifter104 why don't you just edit it, or simply add a comment suggestion improvements? The answer is correct! Now it's more complete.... – superhero Jul 14 '16 at 13:29
  • The overall parts were there but not in a way that someone looking for a solution to a similar problem could of found all that easy to put together. Now however it is a complete answer and I have reversed the downvote accordingly. – Drifter104 Jul 14 '16 at 13:57

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.