Matt McManis
Matt McManis

Reputation: 4675

SSL NGINX Wont Load

I'm trying to set up SSL with NGINX.
It worked with port 80 before changing to 443 and adding file paths.


I genereated the csr and key.

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr

I followed this guide and this guide and have received my crt and ca-bundle from Namecheap/Comodo.


I combined the files for NGINX:

cat example_com.crt example_com.ca-bundle >> cert_chain.crt and put in /etc/nginx/ssl/.

Set Permission

sudo mkdir /etc/nginx/ssl
sudo chown -R root:root /etc/nginx/ssl
sudo chmod -R 600 /etc/nginx/ssl

sudo ls -l returns -rw------- 1 root root

Sites-Available:

server {
    listen 443;

    ssl on;
    ssl_certificate /etc/nginx/ssl/cert_chain.crt;
    ssl_certificate_key /etc/nginx/ssl/example_com.key;
...

My /etc/nginx/nginx.conf doesn't use any ports, thats all in the example.com sites-available.

When I reload NGINX:

sudo systemctl reload nginx or sudo systemctl restart nginx

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Sun 2017-03-26 22:16:54 UTC; 5h 8min ago
Process: 3998 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 3993 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=1/FAILURE)
Process: 3885 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 4000 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 3888 (code=exited, status=0/SUCCESS)

Upvotes: 0

Views: 584

Answers (1)

Matt McManis
Matt McManis

Reputation: 4675

I found the answer was to remove the extra linebreaks and whitespace in the cert, which was added by Comodo.

So that this

...
-----END CERTIFICATE REQUEST-----

-----BEGIN CERTIFICATE REQUEST-----
...

Looks like this

...
-----END CERTIFICATE REQUEST-----
-----BEGIN CERTIFICATE REQUEST-----
...

Also note that copy pasting into nano will insert extra whitespaces at the end of a line. I used vim instead.

Upvotes: 2

Related Questions