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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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:
- sudo nginx -t
I would also recommend checking your Nginx error log as well:
- sudo tail -100 /var/log/nginx/error.log
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.