Logo

dev-resources.site

for different kinds of informations.

Day 32: Securing Your Personal Blog with SSL/TLS (A Beginner's Guide)

Published at
12/10/2024
Categories
ssl
devops
webdev
programming
Author
arbythecoder
Categories
4 categories in total
ssl
open
devops
open
webdev
open
programming
open
Author
12 person written this
arbythecoder
open
Day 32: Securing Your Personal Blog with SSL/TLS (A Beginner's Guide)

Let's face it: Nobody wants their personal blog to be vulnerable. A few weeks ago, I was setting up a new blog on Kubernetes, and I realized how crucial it was to secure it with SSL/TLS. This tutorial will walk you through the process, even if you're new to Kubernetes. We'll use the Nginx Ingress Controller and Cert-Manager to make it easy.

Objective: Secure a simple application (like a personal blog) running on Kubernetes using SSL/TLS certificates automatically obtained from Let's Encrypt.

Prerequisites:

  • A Kubernetes cluster (Minikube is a great option for beginners!).
  • kubectl configured to access your cluster.
  • A basic understanding of Kubernetes concepts (we'll explain the important ones as we go!).

Steps:

1. Install Nginx Ingress Controller:

The Nginx Ingress Controller acts as a reverse proxy, directing traffic to your application. Think of it as a smart bouncer for your blog.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml
Enter fullscreen mode Exit fullscreen mode

This command applies a YAML configuration file. This file creates all the necessary Kubernetes components (namespaces, service accounts, etc.) to run the Nginx controller.

What's happening here? We're using a pre-built YAML file to automate the deployment. It handles the complexities of setting up the controller, so you don't have to!

2. Verify Installation:

Let's check if the controller is running.

kubectl get pods -n ingress-nginx
Enter fullscreen mode Exit fullscreen mode

You should see pods with a "STATUS" of "Running". If you see any errors, check the pod logs for clues: kubectl logs <pod-name> -n ingress-nginx.

3. Install Cert-Manager:

Cert-Manager automates the process of getting and renewing SSL certificates from Let's Encrypt. It's like a magic certificate machine!

kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
Enter fullscreen mode Exit fullscreen mode

This installs Cert-Manager. [Insert Screenshot of the command and successful output.] Make sure you're using a compatible version.

4. Create a Certificate Issuer (Let's Encrypt Configuration):

We need to tell Cert-Manager to use Let's Encrypt. Create a file named issuer.yaml with this content, replacing <[email protected]> with your email address:

apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: <[email protected]>
    privateKeySecretRef:
      name: letsencrypt-prod
    solvers:
    - http01:
        ingress:
          class: nginx
Enter fullscreen mode Exit fullscreen mode

This configures Cert-Manager to use Let's Encrypt for certificate issuance.

5. Apply the Issuer:

kubectl apply -f issuer.yaml
Enter fullscreen mode Exit fullscreen mode

This makes the Let's Encrypt configuration active.

6. Configure Ingress with TLS:

Now, let's secure your blog! Create ingress.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-blog-ingress
  annotations:
    cert-manager.io/issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - myblog.example.com  # Replace with your domain
    secretName: my-blog-tls
  rules:
  - host: myblog.example.com # Replace with your domain
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-blog-service # Replace with your service name
            port:
              number: 80
Enter fullscreen mode Exit fullscreen mode

Remember to replace placeholders with your domain and service name.

7. Apply the Ingress:

kubectl apply -f ingress.yaml
Enter fullscreen mode Exit fullscreen mode

This creates the Ingress resource. Cert-Manager will automatically start getting your certificate.

8. Test the Secure Ingress:

Once the certificate is issued (check the status of the secret my-blog-tls), access your blog via HTTPS: https://myblog.example.com.

Likely Challenges Encountered:

  • DNS Propagation: It might take time for your DNS changes to take effect. Be patient!
  • Rate Limits: Let's Encrypt has rate limits. If you encounter issues, try again later.
  • HTTP-01 Challenge: This challenge requires your Ingress controller to be publicly accessible. Check your firewall settings.
ssl Article's
30 articles in total
Favicon
Building and Deploying a New API (Part 3)
Favicon
Using Cloudflare SSL with Elastic Beanstalk instances
Favicon
Generate your Let's Encrypt Digital Certificates for all your domains using Apache
Favicon
Renew LetsEncrypt SSL Certificate in WordPress by Bitnami
Favicon
Building an S3 Static Website with CloudFront Using Terraform
Favicon
You May Prefer to Know Less About PKI Flaws but Now Is Too Late
Favicon
Understanding SSL and Its Importance
Favicon
Heartbleed: The Bug That Shook the Internet
Favicon
How to Ignore cURL SSL Errors
Favicon
Secure Nginx with Let's Encrypt on Ubuntu
Favicon
How to Update SSL Certificate in SafeLine WAF through a File
Favicon
Deploy Vite-React Project in AWS EC2 using custom domain and free SSL Certificate.
Favicon
5 Steps for a Quick and Effective Transition to 90-Day TLS/SSL Certificates
Favicon
Guide to SSL Errors: What do they mean and how to fix them
Favicon
How to remotely EV code-sign a windows application using ssl.com
Favicon
Instant Domain Insights: Why Every Tech Professional Needs DNS Checker Pro
Favicon
INSY 8211 & Intro to Linux Administration - part_1 [Network and Web Server Configuration]
Favicon
Day 32: Securing Your Personal Blog with SSL/TLS (A Beginner's Guide)
Favicon
Understanding SSL/TLS: The Role of Encryption and Security Protocols in Internet Communication
Favicon
Get a free SSL certificates for your shared-hosting cPanel domain!
Favicon
Choosing an SSL certificate: paid or free — or whether you can do without one
Favicon
Chain of Trust: Decoding SSL Certificate Security Architecture
Favicon
Docker Server Certificate with SSL
Favicon
HTTPS and SSLs: Why They Matter, How to Use Them
Favicon
🚀 Deploying Node.js Application with PM2, NGINX, and SSL Configuration 🚀
Favicon
Types of SSL Certificates
Favicon
AWS Certificate Manager Implementation
Favicon
Migration vom Nginx Proxy Manager zu Traefik 🚀
Favicon
Migrating from Nginx Proxy Manager to Traefik 🚀
Favicon
Self hosted supabase setup with Authelia and Caddy

Featured ones: