title: nginx ssl_certificate directive doesn't work within server block, browser shows ERR_CONNECTION_CLOSED or ERR_CONNECTION_RESET
body: <p>I'm trying to serve multiple TLS-secured domains out of a single VPS with Nginx v1.8.0, but for some reason it's just not taking the certificate configuration in the server block. When I put the <code>ssl_certificate</code> and <code>ssl_certificate_key</code> directives in the http block, it works fine. But when I try to put them into the server block instead, there are no errors at startup, nothing in the logs, but chrome gives me an <code>ERR_CONNECTION_CLOSED</code> message. This has to be easier than it seems....</p>
  
  <p>Here's the setup that works:</p>
  
  <p>nginx -V output:</p>
  
  <pre><code>nginx version: nginx/1.8.0
  built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) 
  built with OpenSSL 1.0.1f 6 Jan 2014
  TLS SNI support enabled
  </code></pre>
  
  <p>My main nginx.conf:</p>
  
  <pre><code>user  http;
  worker_processes  3;
  pid /var/run/nginx.pid;
  
  error_log  /var/log/nginx_error.log error;
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       mime.types;
      default_type  text/plain;
      sendfile        on;
      keepalive_timeout  65;
      index index.php index.html;
  
      log_format  main  '$remote_addr - $remote_user [$time_local], "$scheme://$host$request_uri", '
                      'file: "$request_filename", http: $status, sent: $body_bytes_sent, ref: "$http_referer", '
                      '"$http_user_agent", "$http_x_forwarded_for"';
  
      access_log /var/log/nginx_access.log main;
  
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  
      server {
        listen 80;
        server_name "";
        return 410;
      }
  
      ssl_certificate /etc/letsencrypt/live/site1.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/site1.com/privkey.pem;
      include vhosts/*.conf;
  }
  </code></pre>
  
  <p>My vhosts directory listing:</p>
  
  <pre><code>site1.conf
  site2.conf
  </code></pre>
  
  <p>And finally, my site1.conf file (site2.conf is essentially the same):</p>
  
  <pre><code># Server block that redirects www.site1.com requests to site1.com
  server {
    listen 443;
    server_name www.site1.com;
    return 301 https://site1.com$request_uri;
  }
  
  # Server block that serves site1.com;
  server {
    listen 443 ssl;
    server_name  site1.com;
    root /srv/www/site1/public_html;
    index index.php index.html index.htm;
  
    error_log /var/log/nginx_err_site1.log error;
    access_log /var/log/nginx_acc_site1.log main;
  
    include global_restrictions.conf;
  
    location / {
      try_files $uri /index.php?q=$uri&amp;$args;
    }
  
    location ~ \.php$ {
      try_files $uri = 404;
      include        fastcgi_params;
      fastcgi_pass   unix:/var/run/php-fpm_site1.sock;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  }
  </code></pre>
  
  <p>As you can see, the <code>ssl...</code> directives are in the main configuration file http block. That configuration works fine. If I remove them from that location, however, and put them into the server block of the site1.conf vhost file, as indicated below, I get the <code>ERR_CONNECTION_CLOSED</code> error.</p>
  
  <pre><code># Server block that redirects www.site1.com requests to site1.com
  server {
    listen 443;
    server_name www.site1.com;
    return 301 https://site1.com$request_uri;
  }
  
  # Server block that serves site1.com;
  server {
    listen 443 ssl;
    server_name  site1.com;
    root /srv/www/site1/public_html;
    index index.php index.html index.htm;
  
    ssl_certificate /etc/letsencrypt/live/site1.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/site1.com/privkey.pem;
  
    error_log /var/log/nginx_err_site1.log error;
    access_log /var/log/nginx_acc_site1.log main;
  
    include global_restrictions.conf;
  
    location / {
      try_files $uri /index.php?q=$uri&amp;$args;
    }
  
    location ~ \.php$ {
      try_files $uri = 404;
      include        fastcgi_params;
      fastcgi_pass   unix:/var/run/php-fpm_site1.sock;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  }
  </code></pre>
  
  <p>I just can't figure it out!</p>
  
  <p>Thanks for any help you can offer.</p>