← Servers, deploying and APIs

Lesson 13 of 20 · Try it · 45 min

2.6 Hands-on: your domain, pointing at your server, with HTTPS

You'll point app. your domain at your server, put the app from item 2.4 behind nginx, and turn on HTTPS.

Steps

  1. Buy your domain if you haven't (Domains → Register a domain).
  2. Add an A record: Host app, Value your server's IP address.
  3. On your laptop, run nslookup app.<your domain> until it shows your IP.
  4. On the server: start the app with pm2 and add the nginx file for app.<your domain> (item 2.4, steps 1 to 4).
  5. Open http://app.<your domain>. You'll see Hello from my app on my own server.
  6. Turn on HTTPS with a free certificate from Let's Encrypt:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d app.<your domain>

Type your email, agree to the terms, and let it set up the redirect to HTTPS.

  1. Open https://app.<your domain>. There's a padlock.

Good to know

  • The certificate renews by itself. sudo certbot renew --dry-run checks that renewing works.
  • Run certbot only for names you set up by hand, like app.. For a website you moved from Lynk (item 2.2), Lynk sets up its certificate itself.

Check your work: https://app.<your domain> shows your app, with a padlock.

Try it in Lynk

Now do it yourself. When you're done, come back here and mark this lesson done.

Sign in to try it
Next lesson

Sign in to save your progress and earn the certificate.

2.5 Domains and DNS records