I’ve tried following three or four tutorials, but I still can’t get my site to load with https. I bought a ssl certificate from namecheap and they gave me three files when I generated the ssl. A Key, A Certificate and the csr. I have saved each in
/root/example.com.crt
/root/example.com.key
/root/example.com.csr
Following along the tutorial found at https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority
I have rebuilt my /etc/nginx/sites-available/example.com
file to be this:
#Redirect from 80
server {
listen 80;
server_name example.com;
rewrite ^/(.*) https://example.com/$1 permanent;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /root/example.com.crt;
ssl_certificate_key /root/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
root /var/www/html;
index index.html;
default_type "text/html";
location / {
try_files $uri $uri/ /index.html;
}
#redirect for api's to node server.
location /api {
# Serve api requests here. This will connect to your node
# process that is running on port 3001.
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Before I tried to get this running on ssl everything was running fine. When I run sudo service nginx restart. Currently it restarts just fine.
I have changed /etc/nginx/sites-available/default to
server {
listen 443 ssl default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
Any thoughts?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there @gabrielsuttner,
The configuration file looks correct, what happens when you try to visit your domain via https? Are you getting any errors?
Also what happens when you run an Nginx config test:
I would also recommend checking your Nginx error log as well:
Another thing that I could suggest is taking a look at this Nginx Config tool here which would help you to generate a correct Nginx configuration file:
https://www.digitalocean.com/community/tools/nginx
Regards, Bobby