Chapter 2: The OSI Model and TCP/IP Model
2.4 Walk-through: what happens when you open a website?
This is my favourite interview question, so pay attention. Suppose you type https://www.example.com in your browser and press Enter. What happens in the next few milliseconds? Come on, let's go through it step by step together.
हा माझा सगळ्यात आवडता इंटरव्ह्यू प्रश्न आहे, म्हणून लक्ष द्या. समजा तुम्ही ब्राउझरमध्ये https://www.example.com टाइप करून Enter दाबलं. पुढच्या काही milliseconds मध्ये काय काय होतं? चला, एकत्र स्टेप बाय स्टेप बघू.
ये मेरा सबसे पसंदीदा इंटरव्यू सवाल है, इसलिए ध्यान दो. मान लो आपने ब्राउज़र में https://www.example.com टाइप करके Enter दबाया. अगले कुछ milliseconds में क्या-क्या होता है? चलो, साथ में स्टेप बाय स्टेप देखते हैं.
You ──► Browser ──► DNS lookup ──► TCP handshake ──► TLS handshake ──► HTTP GET
│
Page shown ◄── Browser renders ◄── HTTP 200 + HTML/CSS/JS ◄── Web server ◄──┘
- URL parsing (L7): The browser finds the scheme (
https→ port 443), host (www.example.com) and path (/). - DNS resolution (application layer): Classic DNS can use UDP or TCP port 53. The browser and operating system use their configured resolution path when a cached result or connection cannot be reused. A recursive resolver can use cached data or follow required referrals to obtain an authoritative result. For the drawing below, use the documentation-only address
192.0.2.40as the example result. - Local next hop: For IPv4 on a typical Ethernet link, ARP can resolve the selected local next hop to a link address. For an on-link destination this can be the destination itself. For a remote destination it is often a gateway. IPv6 uses Neighbor Discovery.
- TCP 3-way handshake for HTTP/1.1 or HTTP/2 (L4): Your laptop picks an ephemeral port (e.g. 51544) and sends SYN to
192.0.2.40:443; the server replies SYN-ACK; laptop sends ACK. Connection established. This walkthrough follows a new TCP-based HTTPS connection. If the client and site use HTTP/3, they establish a QUIC connection over UDP instead. Connection reuse and DNS caching can also skip steps in a repeat visit. HTTP/3 specification - Routing (L3): Forwarding carries the transport handshake and later packets over the selected path. Address translation can change addresses or ports where it is configured.
- TLS handshake for this TCP path: The client negotiates protection with its TLS peer and verifies the peer identity and trust configuration. TLS placement and termination depend on the actual protocol path.
- HTTP request (L7): Browser sends
GET / HTTP/1.1with headersHost: www.example.com, cookies, etc. - Server processing: On AWS this could be: Security group allows 443 → Nginx receives request → serves a static file or proxies to an app (Node/Flask/PHP) → app queries the database → response generated.
- HTTP response (L7):
HTTP/1.1 200 OKplus HTML. The browser then requests CSS, JS and images (often over the same connection). - Rendering: Browser builds the DOM, applies CSS, runs JavaScript and shows the page.
- Connection close / keep-alive: Connection reused for more requests, then closed with FIN/ACK.
Now open your terminal and try this with me – you can see many of these steps yourself:
आता टर्मिनल उघडा आणि माझ्यासोबत हे ट्राय करा – यातल्या बऱ्याच स्टेप्स तुम्ही स्वतः बघू शकाल:
अब टर्मिनल खोलो और मेरे साथ ये ट्राय करो – इनमें से बहुत से स्टेप्स आप ख़ुद देख पाओगे:
# Step 2: DNS lookup
dig +short www.example.com
nslookup www.example.com
# Step 5: path taken by packets (install traceroute if missing)
traceroute www.example.com
# Steps 4, 6, 7, 9 in detail (verbose curl)
curl -v https://www.example.com -o /dev/null
Troubleshooting using layers
Website not opening from your laptop? Work bottom-up: Is the EC2 instance running and are its status checks healthy? Does it have a public IP and route to an IGW (L3)? Does the security group allow port 80/443 (L4)? Is Nginx listening (ss -tlnp)? Does DNS point to the right IP (L7)? Does the app return errors (L7)?
When Mauli Dairy calls to say "the site won't open", use the order from the note above: instance running → public IP and route → security group 80/443 → Nginx listening (ss -tlnp) → DNS → app errors. One command for each step, no guessing.
Mauli Dairy चा फोन आला की "साइट उघडत नाही", तर वरच्या नोटमधला क्रम वापरा: instance running → पब्लिक IP आणि route → सिक्युरिटी ग्रुप 80/443 → Nginx listening (ss -tlnp) → DNS → ॲप errors. प्रत्येक स्टेपला एक कमांड, अंदाज नाही.
Mauli Dairy का फ़ोन आया कि "साइट नहीं खुल रही", तो ऊपर वाले नोट का क्रम इस्तेमाल करो: instance running → पब्लिक IP और route → सिक्योरिटी ग्रुप 80/443 → Nginx listening (ss -tlnp) → DNS → ऐप errors. हर स्टेप के लिए एक कमांड, अंदाज़ा नहीं.
Ravindra Bagale's Tip
When a website won't open, talk through the troubleshooting layer by layer, out loud, like a checklist: instance running? → route and public IP? → security group port? → is the service listening? → DNS correct? → app errors? Interviewers like this structured approach far more than random guesses.
Ravindra Bagale's Tip – मराठी
Website उघडत नाही तेव्हा troubleshooting layers प्रमाणे, मोठ्याने, checklist सारखं बोला: instance running? → route आणि public IP? → security group port? → service listen करतो का? → DNS बरोबर? → app errors? Interviewers ना random अंदाजापेक्षा ही structured पद्धत खूप जास्त आवडते.
Ravindra Bagale's Tip – हिंदी
Website नहीं खुल रही तब troubleshooting layers के हिसाब से, ज़ोर से, checklist की तरह बोलो: instance running? → route और public IP? → security group port? → service listen कर रही है क्या? → DNS सही? → app errors? Interviewers को random अंदाज़े से ये structured तरीका बहुत ज़्यादा पसंद आता है.
Ravindra Bagale's Tip
Many students assume the server is down when ping fails. An unanswered ICMP probe can have several causes. For your approved web service, use its intended name, port and normal GET request. Keep ordinary certificate validation for HTTPS. An HTTP response and an ICMP reply answer different questions.
Ravindra Bagale's Tip – मराठी
बरेच students ping fail झाला की server down असं समजतात. ICMP ला उत्तर न मिळण्याची अनेक कारणे असू शकतात. परवानगी असलेल्या web service चा योग्य hostname, port आणि GET request वापरा. HTTPS साठी certificate verification चालू ठेवा. HTTP response आणि ping reply वेगवेगळी माहिती देतात.
Ravindra Bagale's Tip – हिंदी
बहुत से students ping fail हुआ तो server down समझ लेते हैं. ICMP का जवाब न आने के कई कारण हो सकते हैं. अनुमति वाली web service का सही hostname, port और GET request इस्तेमाल करें. HTTPS में certificate verification चालू रखें. HTTP response और ping reply अलग जानकारी देते हैं.
Lab
Chala, dig +short www.example.com, traceroute www.example.com aani curl -v https://www.example.com -o /dev/null chalva. Output madhe varchya 11 steps paiki kontya steps disat aahet te mark kara – resolved IP (step 2), TCP connect (step 4), TLS handshake (step 6) aani 200 status (step 9).
Begin with the browser decision you actually want to observe
Imagine a student sees a message in the training group that registration has opened. The student pastes https://portal.training.example/classes?id=24#seats into the address bar and presses Enter. The exact address matters to the example. The screen may display the class page, a certificate error, a login screen, an application error or a timeout. Those are different kinds of result. Following what happens from the first input gives you a way to explain which evidence each result contains.
First describe the path we are modelling. We will follow a first visit using a fresh HTTPS connection over TCP and a domain name reserved for illustration. There is no usable cached page at the start. The browser needs an address, the endpoint needs a working listener, and the user wants a particular application resource. Later we will change one of those conditions. In an actual browser, DNS caching, shared proxy behavior, HTTP/3 and existing connections can adjust what happens in the first few moments. State the assumed path when answering an interview question instead of promising one universal script.
Try answering in ordinary words before giving numbers. The browser interprets the address, finds a network destination when needed and sets up a communication path under the specified security rules. It asks for the resource and processes the response. It may then ask for additional resources and render them. Now add the protocol names and layer reasoning under those steps. An interview answer that starts from the user's goal makes more sense than reciting protocol names without explaining what the browser wanted.
Parse the address into decisions
A URL is a structured address. The scheme describes the kind of access the browser will attempt. For https, the browser expects to protect the HTTP exchange and uses the ordinary default port 443 unless the URL specifies another port. The host is portal.training.example. The path is /classes, the query is id=24 and the fragment is seats. The browser can interpret these parts differently even though a student reads them as one line.
The web request normally includes the path and the specified query. The fragment after the hash refers to something interpreted by the client and does not become part of the ordinary request target. A browser can scroll to a matching element after loading the document. App code that runs after arrival may later make its own requests, so observability is still useful. For the initial server request, a missing #seats in the access log is expected. The server logs can include the requested application path and query if those fields are configured to be recorded.
A change to one part can move the failure to a different stage. Adding an invalid explicit port can prevent a connection. Changing the host name can affect DNS, the certificate identity the browser expects and application routing. Changing only id=24 to id=25 often keeps the same host and transport path while selecting different application data. Changing only the fragment can be handled locally for an already loaded document. Save the full intended URL in your practice notes with sensitive fields omitted.
Compare an address typed from memory and one copied from an approved link. A copied link may include a query that selects another resource. A browser can also interpret ambiguous input as a search rather than as a URL. When testing, use the complete scheme and host to remove that ambiguity. Check the address bar after redirects. You may be observing a later request than the one originally described, and a redirect to a different name can introduce a new resolver and connection decision.
Follow the name resolution your client actually used
When the browser needs an address, it uses the name-resolution behavior available in that environment. The application, operating system, network configuration or an approved proxy may take part. A configured recursive resolver can answer with cached data or obtain information from other naming servers. Some browsers can use an encrypted DNS service and may not follow the same lookup route as a different command-line tool. Treat caches and resolver selection as configuration details to discover, rather than a guaranteed order of invisible operations.
For our paper trace, the resolver has no usable cached address. It follows the DNS hierarchy to find authoritative information for the name. A root server can refer it to servers responsible for a top-level domain. The next step can locate the servers responsible for the relevant child zone. An authoritative server provides the zone's published information. The recursive resolver does the multi-step work and returns the usable result to the client. A real lookup can start later in that chain when intermediate records are still cached.
An IPv4 address in a DNS response arrives in an A record. An IPv6 address can arrive in an AAAA record. A name may have more than one suitable result or point through another name. The final destination also depends on which address is usable from the client's network. Some client algorithms try available IPv6 and IPv4 paths in a coordinated way to avoid waiting too long for an unusable one. A terminal test that requests only one address family can see a different outcome from the browser's automatic choice. Note the destination actually used in the connection trace.
Imagine the practice portal changed IPv4 addresses. The zone operator assures you the new value is published. One client still sees the previous result. Read the timing and caching details before changing the web app. DNS time to live controls reuse of eligible cached information and can explain an overlap period. A separate HTTP cache can hold a saved response after the name lookup has changed. Do not confuse a cached DNS record with a cached web page. Comparing a name answer and a response body tells you which cache could account for the difference.
A failed lookup usually provides stronger evidence than “the site is down.” It identifies which name the resolver could not answer or which lookup path failed to respond. Check exact spelling and resolver configuration. On AWS an instance inside a VPC may use VPC Resolver or another configured source. A workstation on the public internet can have different DNS visibility from an instance using private hosted-zone configuration. Compare from the intended environment. Checking an unrelated public resolver cannot prove the private application's lookup behavior.
Choose the first hop before the transport handshake arrives
For this example give the resolved service the documentation address 192.0.2.40. The laptop has 10.25.1.40 in a classroom network with prefix 10.25.1.0/24. That prefix covers the local addresses in the drawing. The documentation address is outside it. The laptop can choose a matching route through a default gateway if no more specific route applies. It is now ready to prepare packets for the remote destination and send them toward the first hop.
On a familiar IPv4 Ethernet segment, the sender can use ARP to learn the local next hop's link address when it does not already know it. If the IP destination is directly reachable on that link, the next hop can be the destination itself. If the destination is remote, the next hop is often a gateway. IPv6 uses its own Neighbor Discovery procedures. Draw the socket endpoint and first link delivery separately. The frame can address the gateway while the carried packet targets the remote service.
A router forwards the IP packet by consulting its own routes. It can move the packet onto a different kind of link, which requires new local link information. Address translation, when used, can change address and port fields at its boundary. Public web traffic does not always pass through customer-side IPv4 NAT, so avoid making translation a mandatory step for every route. If you include a translation device, mark the values before and after translation when comparing logs from its two sides.
The transport handshake is itself carried over this path. The SYN is not sent into a separate future routing stage. The first SYN uses the available route and link delivery. The response must also find a working path back. Treat the route, allowed direction, destination and expected listener as dependencies of the transport exchange. This is a useful correction when a beginner's outline says that all routing starts after the handshake.
Establish transport and interpret its first outcomes
In the fresh TCP case, the client sends a SYN to the chosen HTTPS address and port. It uses a temporary local source port, so more than one local program can have its own exchanges. The responsive peer can return SYN-ACK, and the client completes the ordinary handshake with an acknowledgement. The operating system can then provide a useful byte stream to the browser's security code. This describes one connection, not one TCP handshake per resource requested later by the browser.
Read the request and reply directions on paper. Suppose the local source port is 51544 and the server port is 443. On the outgoing packet the destination transport port is 443. On the reply in this same exchange the destination transport port is 51544 at the client, subject to any transformation on the path. That distinction helps explain why a subnet control evaluating both directions must use the applicable packet values. If a proxy later initiates an origin connection, it supplies its own endpoint values. Do not use the browser's source port to describe every following leg.
The user can observe different failures before the HTTP step. If an outgoing attempt receives an explicit rejection, the client can report a refusal quickly. If it waits and sees no usable response, it may time out. The messages are clues and can have several causes. Compare the actual destination, whether the intended listener exists and whether there is a return path. A local application log may show nothing if the connection never reached it. A lack of application records does not identify the failed device by itself.
HTTP/3 changes the transport path. With a suitable client, server and network, the browser can use QUIC over UDP and exchange HTTP/3 messages. QUIC establishes its own connection and uses TLS security within the protocol. There is no ordinary TCP SYN, SYN-ACK and ACK for that QUIC connection. A browser can also select another HTTP version due to supported features or reachability. When looking at a trace, check whether the client used TCP or QUIC before deciding a handshake is missing.
Negotiate protection and check the web service's identity
In the TCP-based HTTPS path, the browser and its TLS peer perform a handshake before ordinary protected HTTP application data is exchanged. They agree on suitable parameters and establish useful cryptographic keys, and the client validates the server identity according to its rules. A public web peer generally presents certificate information. The client checks that the identity matches the intended service name and that the certificate chain and validity are acceptable in its trust configuration. The correct result is more than “the port was open.”
For example, a certificate valid for portal.training.example does not automatically cover other.training.example or a numeric IP address. The relevant identity values must be carried in the certificate according to the validation method. Many HTTPS peers can host several sites on one address. A supported client can indicate its requested server name during security setup so the peer can choose related service configuration. That TLS name information and the later HTTP host or authority support related but distinct decisions.
An important troubleshooting habit is to preserve the hostname when comparing a different address. A raw IP URL can change which certificate identity the tool expects and which site the frontend selects. If you control the lab, supply one socket address for the original name under a request-specific override and keep certificate validation normal. The lab below lets you see this difference with a disposable certificate. A rejected certificate does not prove the remote machine is offline. It tells you that a required trust or identity check could not be completed for the observed peer.
Draw where encryption ends. The browser can talk securely to a proxy or load balancer. That endpoint can read the HTTP information to select a rule under the configured design. It can send an independent request to the intended origin, which may have its own TLS settings. The client cannot verify the origin's entire internal path just by seeing the public certificate. Strong evidence for both legs comes from their actual configuration and results. Ask which component validated which identity and where another connection began.
Send one HTTP request and follow its responder
For the classroom URL, a typical browser navigation results in a GET for the class resource. In HTTP/1.1 you can picture a request line with method and path plus query and a host field. Other HTTP versions encode the request differently, while preserving the idea of a method, target and authority. The browser can add fields describing available representations or connection context. Treat cookies and authorised tokens as secrets. For a class exercise use a public practice document or local fixture containing no credentials.
The receiving application or intermediary interprets the request. A reverse proxy can choose a target using the host and path. A web server can serve a static file directly so the application database never sees the request. A dynamic handler can read the requested class ID, check permissions and retrieve a matching record. Some operations run over private backend connections. Each backend dependency has its own name, route, transport and application semantics. An external client sees the response chosen by the component speaking to it.
Read a response in parts. A status expresses the operation’s outcome. Headers provide metadata such as how to interpret content, whether a redirect has a target or how long a cache can reuse an answer. The body can contain HTML, JSON, an image or error content. An expected 200 body is strong evidence for that request, but a status number alone can be misleading. A login page or a generic proxy result can have a successful status. Match the response body or safe marker to the intended practice resource.
Consider a missing page. A client receives a 404. The HTTP exchange worked far enough to return that response. A URL path may have been incorrect, routing may have directed the client to a different site, or the intended application may be missing a resource. Use the response and approved access logs to identify which component sent the answer. A 404 received at the browser cannot prove that the expected origin is healthy. A connection failure provides different evidence because no new HTTP response from that endpoint was obtained.
Learn to use a diagnostic method that matches the actual request. A HEAD request asks for response information without transferring the ordinary response body. Some lab routes are configured for GET and may behave differently when called with HEAD. If the goal is to validate a GET route, send GET and print response headers while discarding the body if appropriate. If you need to verify returned data, retain the harmless sample body. Using a different method than the real page can produce an unrelated failure or success.
Render the first response and handle the next requests
When the browser receives an HTML document, it begins interpreting its structure. It can find links to stylesheets, images and scripts, some of which require additional requests. It can create a document object model, which represents the document as a hierarchy browser features and scripts can interact with. Styling rules influence how the elements appear. Scripts can update the page after it begins loading. The initial network exchange can succeed while the finished interface is blank or partly broken for a different reason.
Work a concrete example. The HTML for the class list contains a marker that says “Registration open,” but its stylesheet request returns 404. The learner sees the words without the expected styling. In the browser network view, the document and stylesheet are separate rows. The application name and the original TCP connection can work while a file path is absent. Inspect the file path and deployment order before replacing certificates. A case-sensitive file name on the new server can make a static asset missing even if it worked on another environment.
Take another classroom example. The document arrives, then a script makes a request for the current seat count. It uses an application API on the same service under an approved setup. The initial HTML can be 200 while the later API responds with a permission error. A user who reports the count is blank is describing a distinct part of the page. Record the project request that produced the count and inspect its expected method, target and session state. The original page's status cannot independently confirm that later operation.
Browser and intermediate caches can avoid some repeat requests or revalidate stored results. An HTTP cache policy describes which responses can be stored or reused. A browser may already have the page, a CSS asset, address records or a reusable connection. Those are different kinds of saved state with different lifetimes. If your second test succeeds too quickly to show the expected steps, ask which information the browser reused. Use a fresh controlled session or an independent small request if the assignment needs observations from a fresh exchange.
A connection can remain open and serve later requests as its protocol and peers allow. HTTP/2 and HTTP/3 can use multiple streams in one connection. Classic examples often show a TCP close sequence after the request because it makes the lifetime easier to draw. A useful diagram marks which connection was opened for this test and which later requests shared it. It need not predict exactly when every browser will close its sockets. Record what you observe at client and endpoint under the lab setup.
Choose the next check from the visible difference
Suppose the web service works in the office but times out at home. First make sure both reports use the same URL, time window and expected response. Compare resolved addresses and which address family the two clients actually used. Then compare transport conditions. If the office sends traffic through an approved private path and home only has a public connection, the expected reachability can differ. A status check for the instance running is useful for the service owner. It is not sufficient to establish a public route, allowed port or application listener.
Suppose a second user obtains the expected front certificate at home but only receives a gateway error for the classes route. Inspect the backend leg and listener rules from the appropriate service owner. An ALB, CDN or another proxy can answer while its origin route has trouble. If an error from the correct application explains the failure, check the requested resource or action rather than widening a VPC rule. If the browser never obtained a connection, start next with the network and listening evidence. Separate one result from every other user's experience.
Write the incident statement after the test. “At 10:30 on the practice network, the name resolved to the expected address and TCP connected. Normal peer checking then rejected the certificate name. The request produced no HTTP status.” This sequence is much stronger than “the browser is broken.” An authorised operator can now compare SNI settings, certificate identity and routing destination. Repeat the exact safe request once the approved change is complete. Preserve the relevant success and negative checks while crossing as few boundaries as possible.
Measure where waiting appeared in the local request
Once the local HTTPS fixture works, you can ask curl to print some event times for that same request. Use its write-out option for the final counters and discard the response body for this one timed check. Keep the separate body check from the earlier lab. Connection exists, expected body and time taken to receive it are different results. Do not remove certificate verification just to obtain a shorter timing.
curl --noproxy '*' --connect-timeout 3 -sS -o /dev/null \
--cacert local-cert.pem \
--resolve portal.training.example:8443:127.0.0.1 \
-w 'status=%{http_code} connect=%{time_connect} tls=%{time_appconnect} first_byte=%{time_starttransfer} total=%{time_total}\n' \
https://portal.training.example:8443/classes.txt
Run this from terminal B while the lab server is still running, using the same directory and port. Expect status 200 and short intervals on an unloaded laboratory computer. The times are seconds measured from the start of the curl operation. The connect point records when the connection completed. The TLS time records when the supported TLS connection completed. The first-byte time tells you when response data began to arrive, and total is the end of the transfer. These are cumulative time points. Comparing their differences helps tell where waiting occurred rather than adding them together.
Use the reading as an example, not a speed benchmark. This request reached a listener on the same machine, and the specified address override avoided an external name lookup. It has no distant routing, production service load or remote database dependency. In a real service with several requests, first identify the exact resource that was slow. A long wait before connection suggests a different investigation from a long apparent wait after security setup and before the first response byte. The latter can still include several kinds of work. Correlate endpoint and origin logs before blaming a database.
Write an evidence line showing the method, path, status and approximate measured stage that dominated that test. Repeat the same safe query a few times only if needed and with an approved fixture. If the values vary, record that they vary rather than declaring an exact timing from one run. A timed request can locate a useful breakpoint. It cannot by itself prove which application worker, network link or cache uses the time.
Follow each redirect before diagnosing the last page
Suppose the portal responds to the class link with a redirect to a sign-in page on an approved login service. The browser makes a new decision using the address in the response. If that address has a different host, the browser can use different name information, certificate checks and application routing. If it remains the same origin, a later request can often reuse an existing connection. A final status describes the last exchange that produced it, which may be different from the service the learner first opened.
On paper, label the first response “redirect,” its target “login service,” and the later target “class page.” If the class request redirects properly but the login host fails certificate validation, the first host did enough work to send the redirect. The observed failure comes from the later path. When troubleshooting an approved service, keep the response stages separate and record the exact safe part of each address. Avoid recording query values that carry private identifiers or credentials. A diagram of two requests is often enough to explain why one service owner can reproduce only part of the user's symptom.
Local HTTPS lab with normal certificate checks
Use this lab to stop a request at a known stage and then change only one value. You need Python 3, a curl build with HTTPS support and OpenSSL 1.1.1 or a compatible later version. Use two terminals from the same Linux or macOS environment. On Windows, a preconfigured Linux classroom environment is one option. The temporary certificate is designed for a made-up host under the reserved .example namespace. No public name is created or modified. The HTTPS listener binds only to the IPv4 loopback interface.
Before you begin, note which results are expected. A request with the intended name and locally specified trust should show the class page. A request with normal verification but no trusted certificate for the fixture should fail a trust check. A request with the certificate trusted but a different name should fail its identity check. A request using the correct name for an absent path should get an HTTP status. All four can use the same connection address and port. Their differences help you read the first failing stage.
Prepare the certificate, key and content
In terminal A create a private temporary directory and move into it. The certificate and key belong only to this test. The certificate includes a subject alternative name, the expected DNS identity the HTTPS client checks in this example. The key is kept in this temporary directory and must not be reused, uploaded or shared. The certificate itself contains public material. In this exercise you will tell one curl invocation to trust that specific local certificate without installing it globally.
HTTPS_LAB=$(mktemp -d)
printf '%s\n' "$HTTPS_LAB"
cd "$HTTPS_LAB" || exit 1
openssl req -x509 -newkey rsa:2048 -nodes -days 1 \
-keyout local-key.pem -out local-cert.pem \
-subj '/CN=portal.training.example' \
-addext 'subjectAltName=DNS:portal.training.example'
printf 'Registration open in the local HTTPS lab\n' > classes.txt
Check that OpenSSL finished before attempting to start the server. It should produce local-cert.pem and local-key.pem in this directory. The options can vary among TLS tools. If your implementation rejects -addext, use the specified OpenSSL environment for this lab. A certificate without the expected name extension will not demonstrate the intended identity check. The password-free private key is temporary and appropriate only for this disposable local exercise.
Run the server on its approved local interface
Use the same shell and working directory. The local Python HTTP server represents a simple endpoint that returns files from this directory. The wrapper uses Python TLS support to establish the protected connection before application data. To limit what can be served, put the public test content in its own subdirectory first. The certificate and private key remain outside that served directory. The port is 8443 rather than the usual default; include it in the client test. Choose another free local port if necessary and update each URL and mapping.
mkdir public
mv classes.txt public/classes.txt
python3 - <<'PY'
from functools import partial
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
handler = partial(SimpleHTTPRequestHandler, directory="public")
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain("local-cert.pem", "local-key.pem")
with HTTPServer(("127.0.0.1", 8443), handler) as server:
server.socket = context.wrap_socket(server.socket, server_side=True)
print("Practice HTTPS listener on 127.0.0.1:8443", flush=True)
server.serve_forever()
PY
The listener should keep running in terminal A while you make test requests from terminal B. If the port is in use, switch this fixture to a free port. Never stop an unrelated listener to clear the exercise port. If the TLS library cannot open a certificate file, inspect your working directory and confirm that both files were created by the preceding command. Do not switch off the client's validation to make a failed lab appear successful. Fix the controlled fixture instead.
Request the correct named resource
Open terminal B and change into the private temporary directory whose path you printed in terminal A. Use the path from your own run. The --resolve option supplies an address for the exact name and port for this curl request. It replaces name lookup for that connection without changing the name written in the URL. The --cacert option supplies the trust material for this invocation. The client should still check that the certificate identity matches the named service.
curl --noproxy '*' --connect-timeout 3 -sv \
--cacert local-cert.pem \
--resolve portal.training.example:8443:127.0.0.1 \
https://portal.training.example:8443/classes.txt
Look for more than a single final line. The verbose trace should show a connection attempt toward loopback, the negotiated TLS arrangement, a sent HTTP request and a received 200. Exact text differs between curl builds. The body should contain “Registration open in the local HTTPS lab.” The server terminal should show the request for the path. Use these observations to identify what happened at each stage. This exercise intentionally bypasses a public resolver by specifying the address, so it does not prove that the example hostname resolves without that mapping.
Change the name, trust and path in separate requests
First keep the trusted certificate but use the second name below. It still connects to the same local listener. The certificate does not identify that second name. Expect a certificate identity error before a new HTTP result. Next use the original name while omitting the specified trust certificate. In a normal training environment that has never installed the test certificate, validation should fail because the fixture is not trusted by the ordinary configuration. Finally restore trust and the original name, changing only the file path to one that does not exist.
curl --noproxy '*' --connect-timeout 3 -sv \
--cacert local-cert.pem \
--resolve wrong.training.example:8443:127.0.0.1 \
https://wrong.training.example:8443/classes.txt
curl --noproxy '*' --connect-timeout 3 -sv \
--resolve portal.training.example:8443:127.0.0.1 \
https://portal.training.example:8443/classes.txt
curl --noproxy '*' --connect-timeout 3 -sv \
--cacert local-cert.pem \
--resolve portal.training.example:8443:127.0.0.1 \
https://portal.training.example:8443/absent.txt
The last request should receive 404, and the server should log the missing file request. Compare its trace with the two certificate failures. Those stopped before issuing a normal protected HTTP request to the listener. The absent file test reached that application and obtained a response. If the untrusted test unexpectedly succeeds, look at whether your curl environment already trusts this specific fixture or uses separate trust configuration. Do not draw a conclusion from the exit code alone. Read the stage and visible response information.
Stop the server in the original terminal with Ctrl+C. Keeping the correct curl options, repeat the same successful test path once before cleaning up. In a free port condition it now fails before TLS and HTTP. Make a short record containing four observations: the working request, the name check failure, the application 404 and the closed port. Add the trust failure as a fifth if your environment exhibited it. These give you concrete evidence for stages that a generic “site didn't open” error could hide.
Leave the temporary directory before removing it. Remove the one public file and its directory, then delete the disposable outputs and empty parent folder. Inspect the path first to verify it belongs to this exercise. There is no need to remove files recursively or change any machine trust settings. Keep the public teaching result if needed, but never copy the private key into your report. The local curl trust setting ended with the command. The test has no AWS instances or paid resources to delete.
printf '%s\n' "$HTTPS_LAB"
cd / || exit 1
rm -- "$HTTPS_LAB/public/classes.txt"
rmdir -- "$HTTPS_LAB/public"
rm -- "$HTTPS_LAB/local-cert.pem" "$HTTPS_LAB/local-key.pem"
rmdir -- "$HTTPS_LAB"
Explain the visit and the failures aloud
How would you answer “What happens when I open a website?” in a short interview?
I would assume a fresh HTTPS visit, then describe how the browser gets the host and path from the URL. It uses cached or new name information to choose a destination. It establishes a transport and protected path and requests the resource under HTTP. A server or intermediary responds, then the browser can fetch more resources and render the page. I would mention how HTTP/3, caches and existing connections can change the observed sequence.
How does a wrong name in a certificate differ from a missing file?
A wrong name is an identity failure when the HTTPS client verifies its peer. It can happen after the transport connection succeeds, before the ordinary HTTP request reaches application handling. A missing file in this fixture produced a 404 after the protected HTTP exchange worked. I would compare the name and destination for the first result and the responder and resource path for the second.
Why does a browser's HTTP result not always tell you whether the origin was healthy?
A proxy or cache can send a result on the frontend connection without the origin serving that request. I would confirm the exact host and path and use the available listener, target and origin evidence for the same attempt. A successful client-side TLS handshake and an HTTP status are evidence about the visible responder. Application or access logs are useful when I need to establish backend handling.
Why might a second visit show no fresh DNS or TCP setup?
The browser or resolver can have a usable saved name result. The browser can also reuse an established connection for compatible requests. It can even have a stored HTTP response. Those are separate forms of reuse. To explain what I observed, I would check which lookup, connection and resource requests actually happened.
Quick quiz
The URL ends with /classes?id=24#seats. Which parts of this example normally form the HTTP request target before any application scripts act?
Check your answer
The path and query are normally sent to the service. The fragment is handled by the client and can identify a position in the returned document. Treat later script requests as separate events.
The local lab client connects to port 8443 and rejects the peer's name. What should you inspect first: the resource filename, the certificate identities and URL hostname, or the browser's stylesheet?
Check your answer
Inspect the certificate and name. The request stopped at the identity check. Finding a different file or stylesheet will not repair the certificate mismatch associated with the chosen name.
The HTML gets 200 and the stylesheet returns 404. What belongs in the next evidence record?
Check your answer
Record the stylesheet's own URL and actual response, then compare the deployed asset path and request routing. The document and stylesheet are separate application requests and can have different outcomes.
Revision cards
Address structure
Parse the scheme, host, port, path, query and fragment. Find which value changed before assuming every connection stage changed.
Fresh or reused
A new lookup or handshake occurs when the client needs it. Cached results and established connections are separate reasons a step may be absent.
HTTPS evidence
A verified peer check adds evidence after transport. Preserve the host name when selecting a test address, and keep certificate validation enabled.
Page and assets
Check the response for the exact resource the user needs. A document, style, script and application API can each succeed or fail independently.
Primary references
- WHATWG URL Standard and RFC 3986 URI structure
- RFC 1034 DNS concepts, RFC 8305 IPv4 and IPv6 connection selection and AWS VPC DNS concepts
- RFC 9293 TCP, RFC 8446 TLS 1.3, RFC 6066 TLS server name indication and RFC 9525 TLS service identity
- RFC 9000 QUIC, RFC 9114 HTTP/3, RFC 9110 HTTP semantics and RFC 9111 HTTP caching
- OpenSSL certificate request command, Python TLS documentation, Python HTTP server and curl manual