Setting Up Self-Signed Certificates
1 min read
- Authors
- Name
- Vijaykumar Rajendran
- @vijayrajendran_

Table of Contents
Self-Signed Certificates
Generate Certificate
sudo openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/nginx/ssl/selfsigned.key \
-out /etc/nginx/ssl/selfsigned.crt
Answer the prompts:
- Country
- State
- City
- Organization
- Common Name (your domain)
Use in Nginx
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/nginx/ssl/selfsigned.crt;
ssl_certificate_key /etc/nginx/ssl/selfsigned.key;
}
HTTP to HTTPS Redirect
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
Important Note
Self-signed certificates:
- ✅ Free
- ✅ Good for testing
- ❌ Browsers show warnings
- ❌ Not for production
Good for testing!