How to add SSL certificate provided by GoDaddy to a website running on Nginx?
This tutorial will show you how to acquire and install an SSL certificate from a trusted, commercial Certificate Authority (CA). SSL certificates allow web servers to encrypt their traffic, and also offer a mechanism to validate server identities to their visitors.
There are 3 types of SSL Certificate available:
test.com.To generate a certificate signing request (CSR):
openssl req -newkey rsa:2048 -nodes -keyout test.com.key -out test.com.csr
This will generate 2 files (.key and .csr).
Go to GoDaddy’s SSL certificate page and register for the ssl certificate by providing the generated .csr file.
Next download the ssl certificate from GoDaddy, select the server type as nginx and download the Zip file.
Once the zip is extracted you should get 2 files: one will be 1235454xxxx.crt and another will look like gd.bundle-g2-1.crt.
Rename the files accordingly and combine them:
cat test.com.crt intermediate.crt > new.test.crt
Now configure Nginx:
listen 443 ssl;
servername test.com
ssl_certificate /etc/nginx/ssl/new.test.crt
ssl_certificate_key /etc/nginx/ssl/test.com.key
If you want HTTP traffic to redirect to HTTPS:
server {
listen 80;
servername test.com
rewrite ^/(.*) https://test.com/$1 permanent;
}
Check configuration and restart nginx:
sudo nginx -T
sudo service nginx restart
Related Articles
How We Set Up Our KVM Hypervisor: From Bare Metal to Production-Ready VM Host
Detailed walkthrough of building a dedicated KVM/libvirt hypervisor with XFS tuning, hugepages, 10GbE tuning, and automation.
Building a Predictable KVM Infrastructure: From Chaos to Control
How to engineer a predictable KVM-based infrastructure focusing on repeatability, observability, and operational safety.
Modular vagrant file
How to structure a modular Vagrantfile using separate .rb config files for resources, disks, and networks.