Skip to content

Add SSL

Video Lecture

Add SSL Add SSL

 (Pay Per View)

You can use PayPal to purchase a one time viewing of this video for $1.49 USD.

Pay Per View Terms

  • One viewing session of this video will cost the equivalent of $1.49 USD in your currency.
  • After successful purchase, the video will automatically start playing.
  • You can pause, replay and go fullscreen as many times as needed in one single session for up to an hour.
  • Do not refresh the browser since it will invalidate the session.
  • If you want longer-term access to all videos, consider purchasing full access through Udemy or YouTube Memberships instead.
  • This Pay Per View option does not permit downloading this video for later viewing or sharing.
  • All videos are Copyright © 2019-2025 Sean Bradley, all rights reserved.

Description

Let's make http://socketio-example.your-domain.tld have an SSL certificate and redirect all HTTP traffic to HTTPS

We can get free certificates from CertBot

Before we start, we should add the server_name setting to our Nginx conf that we created for our socketio-example website.

cd /etc/nginx/sites-enabled/
nano socketio-example.conf

Add the highlighted line, and change YOUR-DOMAIN-NAME to be your domain name.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
server {
    listen 80;
    listen [::]:80;
    server_name  YOUR-DOMAIN-NAME;

    location /socket.io/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass "http://localhost:3000/socket.io/";
    }

    location / {
        proxy_pass           http://127.0.0.1:3000/;
    }
}

Now we can install Certbot and enable the command.

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

And now run it.

sudo certbot --nginx

Note

If your domain name hasn't fully propagated across the internet yet, then CertBot will not be able to validate your request with your IP and you will need to try again an hour or so later.

Now visit https://socketio-example.your-domain.tld

or visit mine to see a working example

https://socketio-example.sbcode.net/