1

I successfully created some LE SSL certs, using this guide.

However, when I updated my nginx config to use the certs and redirect all port 80 traffic to 443. http successfully redirects to https, the site doesn't load. The browser detects that I have a valid cert, but says I do not have a secure connection. This is what I have in my /var/log/nginx/error.log:

2016/03/08 00:11:49 [error] 7301#0: *14 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 55.555.55.555, server: 0.0.0.0:443

The error says I have no SSL cert defined, despite the fact that I do. This is my config:

server {
  listen 443 ssl;
  server_name cooldomain.pizza www.cooldomain.pizza
  ssl_certificate /etc/letsencrypt/live/cooldomain.pizza/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/cooldomain.pizza/privkey.pem;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

  root /home/ubuntu/www/cooldomain-pizza;
  index index.php index.html index.htm;

  server_name cooldomain.pizza www.cooldomain.pizza;
  charset utf-8;

  location / {
    try_files $uri $uri/ =404;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
  }

  location ~ \.php$ {
    try_files $uri $uri/ =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

I'm running Ubuntu 14.04 with Nginx 1.4.6.

Any idea what is happening? I had to roll back the SSL version of the site and go back to being port-80-only.

3
  • 1
    check the permissions on the keys, and verify the cert against your local env CA. ie: openssl x509 -in certificate.crt -text -noout – Matt Joyce Mar 8 '16 at 0:43
  • 2
    You need to reload or restart nginx after changing its configuration. Note that it won't reload or restart if there is a configuration error. Run nginx -t to check for errors. – Michael Hampton Mar 8 '16 at 1:19
  • I'm voting to close this question because problems with tutorials should be addressed to their author. – user9517 Mar 8 '16 at 7:15
7

You appear to be missing a semicolon at the end of the server_name directive. I suspect this is causing the following line to be interpreted as part of the server_name directive rather than as a new directive.

-1

I had the same issue. It helped me to put

default_server

into listen directive.

1
  • default_server is a catchall that tells Nginx to send any requests for domains that aren't explicitly configured to that server. If you configure Nginx correctly it won't be necessary. If you do this on an SSL server the web browser may get a certificate mismatch warning if the certificate in use doesn't match the domain typed into the web browser. – Tim Apr 11 '17 at 1:10

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.