DevTinder runs at http://13.233.x.x: hard to remember, not trustworthy-looking, and not encrypted. In this final chapter you'll connect a domain name, learn how DNS turns names into IP addresses, put Cloudflare in front of your server, and switch everything to HTTPS.
In this chapter you'll learn
- what a domain name, a registrar and DNS are
- how a DNS lookup works, step by step
- the DNS record types you'll use: A, AAAA, CNAME, NS, MX, TXT, and what TTL means
- moving DNS to Cloudflare by changing name servers
- pointing your domain at the server, and updating Nginx
- HTTPS: certificates, Cloudflare's SSL modes, and Let's Encrypt
Before you start: read Chapter S3 02: Nginx and Backend Node App Development. You need an Elastic IP on your instance (Chapter S3 01: Lanching an AWS Instance and Deploying frontend).
Domains, registrars and DNS
- A domain name is a human-friendly name for a server:
devtinder.in. - You rent it, usually yearly, from a registrar: GoDaddy, Namecheap, Hostinger, Cloudflare and others.
- DNS (Domain Name System) is the internet's phone book: it translates names into IP addresses (Chapter 11: Creating the Server).
How a DNS lookup works
When you type devtinder.in into a browser:
- The browser checks its own cache, then asks the operating system.
- If neither knows, the question goes to a DNS resolver (from your ISP, or a public one like
1.1.1.1or8.8.8.8). - The resolver asks a root server: "who handles
.in?" - The root points to the
.inTLD servers (TLD = top-level domain). - The TLD servers answer: "
devtinder.inis handled by these name servers". - The resolver asks those authoritative name servers for the record, and gets the IP address.
- The resolver caches the answer (for the record's TTL) and returns it to the browser, which connects to that IP.
The name servers are the key: whoever runs them controls the domain's DNS records.
DNS record types
| Record | Points a name to | Example |
|---|---|---|
| A | an IPv4 address | devtinder.in → 13.233.10.20 |
| AAAA | an IPv6 address | devtinder.in → 2406:da1a::1 |
| CNAME | another name (an alias) | www.devtinder.in → devtinder.in |
| NS | the domain's name servers | devtinder.in → joel.ns.cloudflare.com |
| MX | the domain's mail servers | for email at @devtinder.in |
| TXT | free text, often for verification | proving domain ownership to Google, email anti-spam (SPF) |
TTL (Time To Live) is how long, in seconds, resolvers may cache a record. A TTL of 3600 means a change can take up to an hour to be seen everywhere. That waiting is what people call DNS propagation.
Step 1: Buy a domain
Buy one from any registrar. The course uses GoDaddy; any registrar works the same way. Make sure you can reach its DNS / name server settings in the dashboard.
Step 2: Move DNS management to Cloudflare
You can manage DNS records at your registrar, but the course moves DNS to Cloudflare, which is free and adds useful features: fast DNS, free HTTPS at the edge, caching and DDoS protection.
- Create a Cloudflare account and add your domain (the free plan is enough).
- Cloudflare scans your existing DNS records and shows them.
- Cloudflare gives you two name servers, for example
joel.ns.cloudflare.comandkara.ns.cloudflare.com. - At your registrar (GoDaddy: My Products → DNS → Nameservers → Change), replace the default name servers with Cloudflare's.
- Wait. Name server changes can take from minutes up to 24–48 hours to reach every resolver worldwide. Cloudflare emails you when the domain becomes active.
From now on, you manage DNS records in Cloudflare, not at GoDaddy (records left at GoDaddy are ignored).
Step 3: Point the domain at your server
In Cloudflare → DNS → Records, add:
| Type | Name | Content | Proxy status |
|---|---|---|---|
| A | @ (the bare domain, devtinder.in) | your Elastic IP | Proxied (orange cloud) |
| CNAME | www | devtinder.in | Proxied (orange cloud) |
- Proxied (orange cloud) means visitors connect to Cloudflare, which forwards traffic to your server. Your real server IP stays hidden, and Cloudflare provides HTTPS, caching and protection.
- DNS only (grey cloud) means Cloudflare just answers DNS; visitors connect directly to your server.
Tell Nginx about the domain:
server {
listen 80;
server_name devtinder.in www.devtinder.in;
# ...root, location / and location /api/ from S3 02 unchanged...
}server {
listen 80;
server_name devtinder.in www.devtinder.in;
# ...root, location / and location /api/ from S3 02 unchanged...
}sudo nginx -t && sudo systemctl reload nginxsudo nginx -t && sudo systemctl reload nginxOnce DNS has updated, http://devtinder.in shows DevTinder.
Step 4: HTTPS
Why HTTPS
HTTPS is HTTP over TLS (Chapter 11: Creating the Server). It gives you:
- Encryption: nobody between the user and the server (public Wi-Fi, ISPs) can read passwords, cookies or data.
- Integrity: nobody can change the page in transit, e.g. inject ads or malware.
- Authentication: a certificate proves the server really is
devtinder.in.
Without HTTPS, browsers mark the site "Not secure", Secure cookies aren't sent (Chapter S2 10: Authentication, JWT & Cookies), and many browser features are disabled.
A TLS certificate is issued by a Certificate Authority (CA) after it verifies you control the domain. Let's Encrypt issues them for free.
Cloudflare's SSL/TLS modes
With a proxied record, there are two connections: browser ↔ Cloudflare and Cloudflare ↔ your server. Cloudflare's SSL/TLS mode decides how the second one works:
| Mode | Browser ↔ Cloudflare | Cloudflare ↔ your server | Verdict |
|---|---|---|---|
| Off | HTTP | HTTP | ❌ |
| Flexible | HTTPS | plain HTTP | ⚠️ looks secure to the user, but the second half isn't encrypted. If Nginx also redirects HTTP → HTTPS, you get an endless redirect loop (ERR_TOO_MANY_REDIRECTS) |
| Full | HTTPS | HTTPS, certificate not verified | better, still not ideal |
| Full (strict) | HTTPS | HTTPS with a valid certificate | ✅ use this |
For Full (strict), your server needs a certificate. Two easy options:
- Cloudflare Origin Certificate (free; valid only between Cloudflare and your server): in Cloudflare, SSL/TLS → Origin Server → Create Certificate, then install the certificate and key in Nginx.
- Let's Encrypt with Certbot (free; a normal public certificate, renewed automatically):
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d devtinder.in -d www.devtinder.insudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d devtinder.in -d www.devtinder.inCertbot gets the certificate, updates your Nginx config to listen on 443, and sets up automatic renewal (certificates last 90 days).
With Certbot and a proxied (orange) Cloudflare record, the domain-ownership check sometimes fails because Cloudflare answers instead of your server. Set the record to DNS only (grey) while running Certbot, then switch it back to proxied.
Then
- In Cloudflare, set SSL/TLS → Full (strict) and turn on Always Use HTTPS.
- Add a rule for port 443 to the EC2 security group (needed when Cloudflare connects to your server over HTTPS, or if you serve HTTPS directly).
- Make the login cookie
secure: truein production (Chapter S2 10: Authentication, JWT & Cookies); withapp.set("trust proxy", 1)from Chapter S3 02: Nginx and Backend Node App Development, Express knows requests arrived over HTTPS. - Pick one canonical address, e.g. redirect
www.devtinder.in→devtinder.in, with a Cloudflare redirect rule or an Nginxreturn 301.
The whole journey
You started Season 1 asking what Node.js is. A request to DevTinder now goes through everything you've learned:
DNS (this chapter) → Cloudflare and TLS → AWS security group and Nginx (Chapter S3 01: Lanching an AWS Instance and Deploying frontend) → reverse proxy to localhost:3000 (Chapter S3 02: Nginx and Backend Node App Development) → PM2-managed Node.js (Chapter 01: Introduction to NodeJs) → Express middleware and routers (Chapter S2 05: Middlewares and Error Handlers, Chapter S2 11: Diving into the APIs and Express router) → JWT auth (Chapter S2 10: Authentication, JWT & Cookies) → Mongoose and MongoDB Atlas (Chapter S2 06: Database, Schema, Models & Mongoose) → and back, with the event loop (Chapter 09: libuv & event loop) juggling thousands of these at once.
Common mistakes
- Adding DNS records at the registrar after moving name servers to Cloudflare: they're ignored.
- Expecting instant DNS changes: wait for the TTL / propagation.
- Cloudflare "Flexible" SSL: half-encrypted, and redirect loops.
- A record pointing at a non-Elastic IP: the site breaks on the next stop/start.
- Forgetting
server_namein Nginx, or forgetting to reload Nginx. - Letting certificates expire: Certbot renews automatically, but check
sudo certbot renew --dry-run.
Key takeaways
- A registrar rents you the domain; name servers (here Cloudflare's) control its DNS records.
- DNS lookups go resolver → root → TLD → authoritative name server, with caching at every step for the record's TTL.
- A = name → IPv4, CNAME = alias to another name, NS = name servers, MX = mail, TXT = verification.
- Point an A record at your Elastic IP, and set Nginx's
server_name. - Use HTTPS everywhere: Cloudflare Full (strict) with an origin or Let's Encrypt certificate, never Flexible.
- Then make cookies
Secure, and redirect to one canonical domain.
Interview questions
Q1. What is DNS, and how does a DNS lookup work?
DNS translates domain names into IP addresses. A lookup checks the browser and OS caches, then asks a recursive resolver, which (if it hasn't cached the answer) asks a root server for the TLD's servers, then the TLD server for the domain's authoritative name servers, then those name servers for the record. The answer is cached along the way according to its TTL.
Q2. What's the difference between an A record and a CNAME record?
An A record maps a name directly to an IPv4 address. A CNAME maps a name to another name (an alias), which is then resolved further. A CNAME can't be used at the bare/root domain alongside other records in standard DNS (some providers offer "CNAME flattening" or ALIAS records to work around it).
Q3. What is TTL in DNS?
Time To Live: how many seconds resolvers and clients may cache a DNS record before asking again. A long TTL means fewer lookups but slower propagation of changes; before migrating a server, teams often lower the TTL in advance.
Q4. How does HTTPS work?
HTTPS is HTTP over TLS. During the TLS handshake, the server presents a certificate (signed by a trusted Certificate Authority) proving it owns the domain; client and server then agree on shared session keys (using asymmetric cryptography for the key exchange). After that, all HTTP data is encrypted with fast symmetric encryption and protected against tampering.
Q5. What is SSL/TLS termination?
Decrypting HTTPS at a proxy or load balancer (like Nginx or Cloudflare) instead of at the application. The proxy handles certificates and encryption, then forwards the request to the app over a private network or localhost (optionally re-encrypted). It centralizes certificate management and offloads crypto work from the app servers.
Q6. What does Cloudflare do when a DNS record is proxied?
Visitors resolve the domain to Cloudflare's IP addresses and connect to Cloudflare's edge, which terminates TLS, applies caching, compression, firewall and DDoS protection, and then forwards requests to your origin server. Your origin's real IP stays hidden from the public.
Q7. Why is Cloudflare's "Flexible" SSL mode a problem?
It encrypts only the browser ↔ Cloudflare connection; Cloudflare ↔ origin traffic is plain HTTP, so the user sees a padlock while data travels unencrypted for part of the way. If the origin also redirects HTTP to HTTPS, it causes an infinite redirect loop. Use Full (strict) with a valid certificate on the origin.
What's next
That's the end of the course: from what Node.js is to a live, secure, full-stack app on your own domain. Good next steps to keep practising:
- add WebSockets for a real-time chat between connections (Chapter S2 19: DevTinder UI - Part 5)
- automate deployments with CI/CD (GitHub Actions)
- add tests for your APIs (Jest + Supertest)
- add rate limiting to login (Chapter S2 09: Encrypting Passwords) and monitoring (PM2 metrics, uptime checks)
- go back to the Interview questions sections and answer them out loud; explaining is the best test of understanding