Chapter 6: Web Servers — Nginx and Apache
6.1 What is a web server?
Friends, so far we have launched a server. But a server without a web server is like a shop with the shutter down — customers come but nobody serves them. Mauli Dairy's customers open the order page, but if nobody is there to answer, they see nothing. Let's understand what a web server really does.
मित्रांनो, आतापर्यंत आपण सर्व्हर लॉन्च केला. पण वेब सर्व्हर नसलेला सर्व्हर म्हणजे शटर बंद असलेलं दुकान – कस्टमर्स येतात पण त्यांना कोणी सर्व्ह करत नाही. Mauli Dairy चे कस्टमर्स ऑर्डर पेज उघडतात, पण तिथे उत्तर देणारा कोणी नसेल तर काहीच दिसत नाही. चला, वेब सर्व्हर खरंच काय करतो ते समजून घेऊ.
दोस्तों, अब तक हमने सर्वर लॉन्च किया. लेकिन वेब सर्वर के बिना सर्वर मतलब शटर बंद दुकान – कस्टमर्स आते हैं पर उन्हें कोई सर्व नहीं करता. Mauli Dairy के कस्टमर्स ऑर्डर पेज खोलते हैं, लेकिन वहाँ जवाब देने वाला कोई न हो तो कुछ नहीं दिखता. चलो, समझते हैं कि वेब सर्वर असल में क्या करता है.
A web server is software that listens on a port (commonly 80 for HTTP and 443 for HTTPS), accepts HTTP requests from browsers and returns responses — HTML pages, images, CSS, JavaScript files, or data produced by an application.
Browser EC2 instance
+--------+ GET /index.html +---------------------------------------+
| | -------------------> | Web server (Nginx / Apache) :80 |
| | | ├─ static file? → read from disk |
| | <------------------- | └─ dynamic? → pass to PHP / |
+--------+ 200 OK + HTML | Node / Python app|
+---------------------------------------+
A web server does three main jobs:
- Serve static content. Use the active site’s mapping to return prepared files such as HTML, CSS, JavaScript and images.
- Handle application requests. Depending on the setup, the server can use an embedded module, send a request through FastCGI or reverse proxy to another HTTP service.
- Handle cross-cutting concerns — TLS/HTTPS, compression, caching, logging, virtual hosts (many websites on one server), load balancing, rate limiting.
Common HTTP status codes
| Code | Meaning | Typical cause |
|---|---|---|
| 200 | OK | Success |
| 301 / 302 | Moved permanently / temporarily | Redirect (e.g. HTTP → HTTPS) |
| 304 | Not modified | A conditional GET or HEAD can use the previously stored representation under the validator conditions. |
| 400 | Bad request | Malformed request |
| 401 / 403 | Unauthorised / Forbidden | 401 concerns valid authentication credentials. 403 is a refusal and can follow an application or filesystem policy. |
| 404 | Not Found | Wrong path or wrong document root |
| 500 | Internal server error | Bug in app / PHP error |
| 502 | Bad Gateway | The gateway could not obtain a usable upstream response. Check the selected target and error details. |
| 503 | Service unavailable | Overloaded or maintenance |
| 504 | Gateway timeout | The gateway did not get a timely response it needed from an upstream. |
Ravindra Bagale's Tip
Remember the gateway’s observation. For 502 it could not use an upstream response. For 504 it did not receive the needed response in time. For 403, read the reported access decision before deciding whether route policy, file permissions or another rule was involved.
Ravindra Bagale's Tip – मराठी
Gateway चा result लक्षात ठेवा. 502 मध्ये usable upstream response मिळाला नाही. 504 मध्ये आवश्यक response वेळेत मिळाला नाही. 403 साठी संबंधित access log किंवा error वाचा आणि कोणता rule लागू झाला ते शोधा.
Ravindra Bagale's Tip – हिंदी
Gateway का result देखो. 502 में usable upstream response नहीं मिला. 504 में ज़रूरी response समय पर नहीं मिला. 403 के लिए संबंधित access log या error देखो और लागू rule पहचानो.
Lab
Chala, start the local practice server in the worked lab below. Compare the existing page, a HEAD response, a separate CSS file and a known missing path. The sample files let you predict and verify the status without depending on an outside website.
Follow a customer's request from address to answer
Mauli Dairy posts a collection timetable for its customers. Asha has saved an HTML file on a Linux machine and can read its text in a terminal. From her phone, the timetable still does not open. The file exists, but a phone needs someone to answer its request. That job belongs to web server software such as Nginx or Apache HTTP Server. It listens for connections, accepts an HTTP request, selects the appropriate handling and sends back an HTTP response. A running machine and a saved file are important pieces. Neither piece alone provides that interaction.
We use the word server in two related ways. An EC2 instance is a machine on which programs can run. A web server is the program performing a particular network job. Several programs can run on the same machine. A single web server can also be configured to handle more than one website. To diagnose a missing page, identify which machine a request reached, which program accepted it and what that program decided. A statement such as “the server is up” needs a clear meaning. The instance can be running while the relevant web listener is absent, or the listener can respond while a particular page is unavailable.
In this lesson, a customer opens a short pickup page that also asks for a stylesheet. We will follow the request and response, then reproduce the essential pattern in a private local exercise. You will see an existing page, a separate stylesheet, an absent path, a HEAD request and a cache validation response. You will also distinguish the status sent over HTTP from the exit status reported by the command you used to retrieve it. These small comparisons let you explain an error before changing a service or opening a network port.
Work through the examples with two questions in mind. What did this test prove, and what additional step would establish the customer result? Receiving an answer for the root page proves that some HTTP responder handled that request. It leaves open whether the stylesheet was served, whether the correct site answered and whether a dynamic operation such as recording an order works. Keep the hostname, method, path and response together when you describe an observation.
Read each piece of the URL before you connect
Consider the example URL https://orders.example.test/pickup?day=morning#times. The scheme identifies the protocol the client intends to use. For HTTPS, HTTP is carried using an encrypted connection with TLS. The hostname orders.example.test is the name the client intends to reach. The path /pickup selects a resource or application route. The query part gives the application extra parameters according to its own design. The fragment after the hash can tell the browser which part of the document to show. That fragment is used by the client and normally does not go to the server in the HTTP request target.
A port identifies a network endpoint on an address. Ordinary HTTP URLs use port 80 if none is given, and HTTPS URLs commonly use 443, according to their scheme defaults. A development service can use an explicit port such as 8080. A listener receives traffic on the address and port it was configured to use. If no program accepts a connection there, the browser may report a connection failure without receiving any HTTP status. If it connects to the wrong address or listener, the response can come from an entirely different website. Read the explicit port, address or hostname before concluding something about a server.
A client usually needs a usable network address for a hostname. Its resolver can consult DNS, its local configuration or a cache. DNS gives information about how to reach a name. It does not tell you whether a particular HTTP route exists. After it has the address, the client attempts the relevant connection. With a normal HTTPS site over TCP there is a TLS negotiation before the HTTP exchange. The client normally validates that the certificate is appropriate for the name it requested. HTTP deployments can use other transport arrangements, including HTTP/3, so describe the actual test rather than assuming every version opens the same kind of connection.
Consider a visitor outside the EC2 instance. Their request can meet a DNS record, a firewall, a load balancer, a proxy and then a website process. The exact path depends on the architecture. Opening a local URL inside the instance can test something useful about a local listener without exercising the path an external visitor uses. This distinction is powerful when you troubleshoot. A local success and a public timeout suggest you need evidence between those two points. A certificate validation error suggests that the client could connect far enough to perform part of the TLS negotiation. Choose the next check where the evidence leaves a gap.
Read a request and its corresponding response
HTTP describes the messages exchanged by client and server. A request has a method and a target, plus headers and, for some operations, content. The method expresses the operation requested. Browsers commonly use GET to retrieve a resource. HEAD asks for response information without the response content. Submitting an order often sends a request such as POST, which the application can use to perform a state-changing action. Select the method that fits your diagnostic. A read of a public page is a different test from submitting a real customer's order.
GET /pickup HTTP/1.1
Host: orders.example.test
Accept: text/html
This is a conceptual HTTP/1.1 example. The first line tells you the method, target path and protocol version used in the example. The Host field tells the listener which hostname the client wants. Other request headers describe the desired response type or send additional context. Different HTTP versions encode these fields in different ways, while retaining the same basic method, target and result semantics. A tool like curl can make the exchange visible enough for a beginner to identify the meaningful parts.
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
<h1>Mauli Dairy pickup</h1>
<p>Morning collection starts at 06:45.</p>
The first line of this illustrative response shows a status. The header fields describe the response content and other handling information. The body here is HTML text for the browser to render. A blank line separates the headers from the body in this representation. The browser can then send separate requests for stylesheet, script, image or API resources named by the page. An HTML status of 200 says how that single request was answered. It does not confirm that the other resources loaded or that the user's complete task works.
Use the body to verify the intended resource as well as the status. A page can return 200 with a default server welcome page, yesterday's content or a useful success message. These are different experiences for the visitor. Test for a known marker, such as the approved pickup time, and review the expected media type if rendering is wrong. A client can also receive an HTML error page where it expected a stylesheet or JSON. The status, type and contents together provide a clearer picture than any one field.
Check the chain of resources behind one browser page
The dairy page has one heading and one style sheet. A browser usually starts by asking for the HTML document. It reads the markup and discovers another URL for the styling. An image could introduce a third request. A script could then fetch data from another route. Each response can have its own status, type, cache behavior and timing. Look at the browser's network panel when you need to find which step broke. The page displayed on the screen can combine successful and unsuccessful requests. The investigation follows the one that changes the user's visible result.
For example, imagine the HTML uses a stylesheet link beginning with a slash. That path is resolved at the origin's root. Another copy might use a relative stylesheet name. If the HTML moves to a folder-shaped URL, the relative asset address can be different from the root-relative one. A useful check is to read the full URL the browser actually requested. Then see what the server returned for that URL. It tells you more than searching the filesystem for any file with the same basename. For the exercise the stylesheet has a known root-relative URL and the correct content can be inspected separately.
Media type is part of the evidence for the returned resource. A stylesheet commonly uses text/css. An HTML document uses a media type such as text/html. An API might use a JSON media type to describe data. A response can have status 200 and still have the wrong body for the consumer. One example is a site's fallback route returning HTML to a browser request for a missing stylesheet. Read the resource's expected bytes or a safe marker and compare its media type. The document's title alone is a weak check for a site with repeated templates.
In an ordinary client, the request's Accept field can express preferences about the kinds of representation the client can use. The response's Content-Type describes the provided content. These fields work in different directions. If a client sends a request body such as JSON, a content type on that request describes the body being submitted. A reproducible API note distinguishes input type from response type. In the static lab you only read resources. You can observe the response type without setting up a real form or a writable API.
When preparing an observation, record the request origin and the path separately. The origin involves the scheme, host and port. A request sent to another origin can meet a different service, policy or cache. Even on one origin, a versioned asset path can have different freshness rules from a frequently updated HTML page. The specific resource and the way it is loaded determine the next check. A customer screenshot identifies the symptom. A request record tells the support team which resource to investigate.
Follow how the server chooses a site and a handler
A server can listen on one address and port for more than one site. In ordinary HTTP handling, the requested authority or hostname helps it select a configuration. Nginx uses the listener and server-name matching rules for its server blocks. Apache can use the listener address and port together with the named virtual host configuration. There can be a default site when a name does not match. On an HTTPS connection, the TLS server-name indication can also help choose a certificate or TLS configuration before the HTTP request is processed. Check the real hostname when testing a site on a shared machine.
Imagine the same EC2 machine has a public pickup site and an internal scheduling interface. Each application can have its own configuration even if both use the same web server program. Each site can route its own paths. The pickup site's root path might map to a specific HTML file. Its stylesheet path might map to a second file. Its order form might send a request to a separate application. This selection happens for each request. Finding the correct landing page from the correct hostname is a first check. Next test the exact path and method involved in the complaint.
For a static response, a common configuration reads a file prepared on disk and returns its contents. A document root is the base directory a site commonly uses for those file lookups. The URL path is resolved according to the server's configuration under that root or another chosen mapping. The URL is not an unrestricted path into the machine's filesystem. A site can have a configured index file for the root, a special mapping for a particular route, or restrictions on which files can be served. Check the active configuration if a static file is present but the URL returns a missing page.
For a dynamic response, a handler may run application logic to select or produce the answer. A reverse proxy accepts the client's request and forwards some requests to an upstream service, then returns that service's response or an appropriate proxy result. A separate application process can look up a timetable or validate a form. Some setups use another integration mechanism, such as FastCGI for PHP-FPM or an embedded server module. Learn which interface the actual deployment uses before assuming every dynamic request is forwarded as HTTP to another port.
The same initial hostname can serve both a static pickup page and a dynamic order endpoint. For the first, useful evidence includes the active root and the file read. For the second, check the proxy or application configuration and the upstream request and response. A successful static page can show that the listener and site configuration answered. It leaves the dynamic handler and its data dependencies to be verified separately. This is why the operator should ask which URL, method and result failed before changing application settings.
Use status codes to choose the next observation
A status code summarizes the responder's result for one request. It is not a full diagnosis by itself. A status can be generated by a web server, proxy, cache or application along the path. Read it together with the actual responder you can identify, the method and path, relevant headers and authorized logs. If you receive no HTTP response, the tool's connection or TLS diagnostic may be the useful evidence instead.
| Status | What the result says | A targeted next observation |
|---|---|---|
| 200 | The responder succeeded for this request. | Check the expected content and media type for the named resource. |
| 301 or 302 | The responder directs the client to another URI. | Read the Location header and check whether the new destination is expected. |
| 304 | A conditional request can use a stored response for the resource. | Check the request validators and the cached representation they refer to. |
| 401 or 403 | The request lacks valid authentication or the responder refuses it. | Identify the actual access policy, challenge and request details. |
| 404 | The responder did not provide a current representation for the resource, or chose not to disclose it. | Check the requested hostname, route, site mapping and authorized diagnostics. |
| 500 or 503 | The responder encountered a server error or is temporarily unable to serve. | Correlate the response with the application status and logs for that time. |
| 502 | A gateway or proxy could not get a valid response from its upstream. | Check which upstream was selected and the configured connection and protocol. |
| 504 | A gateway or proxy did not receive the timely upstream response it needed. | Check timing and the upstream dependency, using the same request context. |
A refusal under 403 can reflect a route policy, permissions, a directory listing policy, a security label or another restriction. A 502 can arise if the proxy cannot use the configured socket or receives unusable upstream data. A different 502 cause can occur even with the application process running. A 504 means the proxy's needed response did not arrive in time, which can involve several systems. Start with the proxy's error evidence and the upstream target. A status alone cannot justify restarting a particular program or broadening a file's access.
A redirect is another useful example. The public URL can respond with 301 and direct the browser to an HTTPS or canonical address. Some tools follow redirects when requested and show the final response. If you are debugging the redirect itself, record the first response and its Location header before following it. A final 200 does not describe how many intermediate redirects ran or which names were involved. Check the intended path and scheme after the final response as well. This explains why two colleagues can report different statuses for what sounds like the same starting URL.
With a conditional GET or HEAD request, a 304 tells the client it can reuse its existing representation under the validation conditions. It normally carries no response content. An earlier copy must belong to the correct resource and its cache rules. Calling every 304 “fresh browser cache” leaves out the conditional request and response that actually happened. In the practice lab we send a known modification timestamp and compare the result to an ordinary GET. That gives you a concrete difference to identify on the wire.
Start a local HTTP server with a known page
Use a laptop or an assigned learning host with Bash, Python 3.7 or later and curl. No web server package, administrative access or cloud resource is needed. The Python standard library will give us a small temporary static server so we can observe HTTP. The lab binds to the loopback address, which is reachable right on the same machine. It serves only a new directory containing the two sample files. It is a teaching fixture. For a managed website, use the separately documented deployment for Nginx or Apache.
Open a first terminal and prepare the two files. One is the public sample page, and the other describes its text color. The page links to the stylesheet by a separate URL path. We set a known modification time on the page for a later validation check. Verify the printed directory before continuing. Stop if setup reports an error or does not print a fresh lab path.
web_lab=$(mktemp -d "$HOME/web-request-lesson.XXXXXXXX") &&
cd -- "$web_lab" &&
mkdir -- ./site &&
printf '%s\n' '<!doctype html>' '<link rel="stylesheet" href="/pickup.css">' \
'<h1>Mauli Dairy pickup</h1>' '<p>Morning collection 06:45</p>' > ./site/index.html &&
printf '%s\n' 'h1 { color: #185781; }' > ./site/pickup.css &&
TZ=UTC touch -t 202501010800 ./site/index.html &&
pwd && ls -l -- ./site
Start the temporary server in that first terminal. The explicit directory prevents serving your surrounding home folder. The bind address limits the service to loopback. Specifying port zero lets the operating system select an available port for this program. The server prints its actual listening port. Keep the process in the foreground and copy the printed port number into your notes. If you run this on a remote learning host, open another terminal connected to the same host for the curl checks. A laptop's loopback address refers to that laptop.
python3 -u -m http.server --bind 127.0.0.1 --directory "$web_lab/site" 0
The process waits for requests. Your first terminal may print a line starting with Serving HTTP on 127.0.0.1 port. It is working even while the output is quiet. You should be able to see the listening address and chosen port without looking up a public IP. If the command fails, read its message and check the Python support provided by your learning system. If the path does not exist, verify setup before starting it again. If you prefer to do the lab on your laptop, you can open the printed local URL there after verifying it belongs to this exercise.
Compare four requests without changing the server
In the second terminal, run the next small block and enter the port printed by the first terminal. This block constructs a URL for the known loopback address and prints it for you to check. If it reports invalid input, repeat it before issuing requests. The host stays the known local address. Your test should not accidentally depend on a public website or a network proxy serving the URL.
unset web_base
read -r -p 'Port printed by the practice server: ' web_port
case "$web_port" in
''|*[!0-9]*) printf '%s\n' 'Enter only the decimal port number.' ;;
*) web_base="http://127.0.0.1:$web_port"
printf 'Practice URL: %s\n' "$web_base" ;;
esac
A URL in the form http://127.0.0.1:PORT contains the same machine and port that the temporary server announced. The displayed value replaces PORT with a real number. Run the following three lines separately once that value is correct. Curl's -i includes the HTTP response headers. The time limit lets you recover your terminal if an intended connection is unavailable. The no-proxy argument applies to requests to this local address for the exercise.
curl --noproxy 127.0.0.1 -sS -i --max-time 5 "$web_base/"
curl --noproxy 127.0.0.1 -sS -i --max-time 5 "$web_base/pickup.css"
curl --noproxy 127.0.0.1 -sS -I --max-time 5 "$web_base/"
The first GET should return status 200 and the two visible text markers, the dairy name and the time. The stylesheet GET should return 200 and contain the color rule, with a content type appropriate to CSS. Compare its bytes to the known file. The HEAD request in the third line should show headers for the page with no response body. A content length, if present, can describe the corresponding GET content even though HEAD did not transfer that body. If the version string says HTTP/1.0 in this lab, that is the small server's default protocol. Read the status number and contents without assuming it must print the same version as the earlier illustrative message.
In the first terminal, look at the lines the server printed for each request. You should be able to point to a GET for the root, a GET for the separate stylesheet and a HEAD for the root. In a real browser, the HTML file itself can direct the browser to make that second type of request. Here curl fetches each path separately so you can see where the two answers come from. An unchanged HTML body and a missing stylesheet would produce a different result for each path. The exact request line and method make the difference verifiable.
Now ask for a path that the setup did not create. This comparison deliberately records both the HTTP status and the shell result of curl. The first invocation displays the status without treating ordinary HTTP error responses as failed transfers. The second asks curl to treat the 404 as an error for this test. Both are requests to the same absent path.
if curl --noproxy 127.0.0.1 -sS --max-time 5 -o /dev/null -w 'HTTP %{http_code}\n' "$web_base/absent.txt"; then
transfer_status=0
else
transfer_status=$?
fi
printf 'Curl status without fail: %s\n' "$transfer_status"
if curl --noproxy 127.0.0.1 -fsS --max-time 5 -o /dev/null "$web_base/absent.txt"; then
transfer_status=0
else
transfer_status=$?
fi
printf 'Curl status with fail: %s\n' "$transfer_status"
Expect HTTP 404 and a zero shell status for the first completed transfer. With the fail option, expect curl status 22 for this exact 404 test and an error diagnostic. A different nonzero result could indicate a connection or client problem. The distinction matters when you write a health check. A command could be successful at exchanging messages and still discover that the named resource is missing. Read the needed HTTP result and content when you want evidence about a page.
Check conditional behavior and clean up the server
Try one additional GET for the page with a header giving the known modification time from the sample file. The exercise uses a fixed UTC timestamp and one server whose file handler supports this check. The client sends a condition about the saved representation. The server can answer that the content is unchanged under that condition so it does not need to send the body again. Use the following request on your running local fixture.
curl --noproxy 127.0.0.1 -sS -i --max-time 5 \
-H 'If-Modified-Since: Wed, 01 Jan 2025 08:00:00 GMT' "$web_base/"
Expect 304 and no HTML body while that unchanged file is served with the intended timestamp. Compare it with the earlier nonconditional GET and HEAD outputs. The HEAD response can report 200 and describe the resource without sending the content. The conditional response has its own meaning: the validator check does not require a new content transfer. If you see 200 for the conditional request, inspect the file timestamp and response headers, then confirm you are talking to your intended server and port. An altered timestamp or different handler changes the premise of the exercise.
When you finish, return to the first terminal and press Ctrl+C to stop your foreground Python process. A later repeat of a local curl request to that now-closed port ordinarily cannot connect unless something else has bound it. That is a different result from 404 while the server was up. Do not treat an arbitrary new process on the port as part of the lab. Check your current terminal and the exact cleanup scope before deleting the generated files. The following block only removes the two known samples and their empty directories.
pwd
ls -la -- ./site
if [ -n "$web_lab" ] && [ "$(pwd -P)" = "$(cd -- "$web_lab" && pwd -P)" ]; then
rm -i -- ./site/index.html ./site/pickup.css &&
rmdir -- ./site &&
cd -- "$HOME" &&
rmdir -- "$web_lab"
fi
Keep any study notes outside that folder before cleanup. The interactive removal names each sample. If you added a file while experimenting, a directory removal will stop while it is still present. Inspect the remaining names and choose the exact additional artifact only if you intend to remove it. The local server did not use a global configuration or require a public firewall rule. Retain the four response observations and the conditional example as your handover evidence.
Separate name lookup, connection, TLS and application evidence
Suppose a colleague sends four messages from different points in a check. One says the name could not be resolved. The second says the connection failed. The third says certificate validation failed. The fourth includes an HTTP status with a returned body. These messages appear in the same familiar client tool, but they place the problem in different parts of the operation. Read the earliest stage for which you have an observation, then ask what evidence can narrow it. An application change is rarely the first response to a name lookup failure.
When the name does not resolve, confirm the intended hostname and which resolver or network context the visitor uses. A private name can exist in one network view and be absent for an outside client. That check can explain why many customers fail before the website sees a request. When the name resolves but the connection fails, verify the address and port, the listener and the intended path through network controls. Absence of an HTTP answer does not give an application status code. Tool output can show a timeout or a refused connection that needs a further check.
With HTTPS, a certificate failure can arise when a client reached a TLS server under a different hostname or when it could not validate the presented certificate. Keep the intended hostname in the check because it affects both certificate validation and site selection. Look at the documented endpoint and certificate setup. A temporary request using an IP address can exercise a different name relationship and show a default site or certificate. That answer does not establish that a visitor using the public name can get through. Diagnose the two requests as distinct observations.
If a valid HTTP response arrives, use its status and content to inspect the next layer. A successful test of a local static file demonstrates that this listener and mapping can answer in that context. A request through a cloud load balancer can reach another target or use a health-check path distinct from the user's route. A test in the visitor's context can include yet another hostname, redirect, HTTPS requirement or asset. The actual application operation is the last evidence in the chain. A plain availability test need not submit real data to establish that the site answers.
Try writing a support note for each message. Name the exact URL and the layer you could reach. State whether the result came from an internal check or a visitor path, and include the timestamp if it matters. If you tested an HTTP response, capture the method, status and one expected content marker. If you failed earlier, describe which stage failed and which environment generated the message. This gives another person the information needed to compare the local and external experiences without guessing which kind of failure “page down” described.
Turn a status into a testable support note
Suppose a customer says they can see the heading but the page has no styling. Start with the page request and the browser's resource panel or a separate request to the stylesheet URL. If the page comes from the right site and the style file returns 404, the listener and page have already answered. The stylesheet route, file deployment or URL is now the next relevant check. If the style request returns an HTML default page with 200, review how the site chooses handlers and what the requested path should return. The browser may refuse to apply unexpected content even when the response is successful as an HTTP transfer.
If the customer reports a delay after submitting an order, identify the scope of an authorized test before using any request that can write data. Inspect the site's actual response and relevant proxy and upstream logs at the reported time. The initial page can still be healthy while the order handler waits on a dependency. An operator can compare a read-only health request and a permitted test transaction under the site's process. Attach the method, hostname, route, timestamp and first observed result. Keep the final user behavior distinct from a lower-level reachability check.
For your own fixture, write a brief result with these pieces. The server listened on loopback at the selected port. The page GET returned 200 with the expected collection time. The stylesheet was a separate request and returned the color rule. A request for the absent path returned 404 while communication still worked, and the conditional page request gave 304 under the known timestamp. The most useful test records describe the system boundary as well as the result. Your evidence applies to this local behavior and prepares you to repeat the same steps for a named site.
Interview questions with worked answers
What does a web server do after a customer enters a URL?
The client resolves and connects to the intended address and port, negotiates TLS if needed, then sends an HTTP request. The web server uses the intended hostname and path to select a site and handler under its configuration. It may read a file or work with an application, then return a status, headers and any content. I would verify the actual URL and content rather than assuming a running instance proves the page can be read.
How can a page return 200 while the browser shows it incorrectly?
The main response might contain the wrong page, or a separate image, stylesheet or script request might have failed. I would check the content marker, each required resource's status and media type, and the requested site. In the lab the HTML and CSS were separate requests, so each could have a different result.
What is the difference between 502 and 504?
Both can describe trouble completing a request through a gateway or proxy. A 502 says it could not use a valid upstream response. A 504 says it did not get the timely upstream response it needed. Inspect the target and time evidence for the request before selecting a repair.
What does a 304 response tell the client?
Under the supplied validation conditions, it can use the previously saved response instead of receiving the new body. I would inspect the method, the condition headers and the stored resource. Our lab supplied a known modification date for a file that had not changed.
Why can curl report success while the HTTP response is 404?
The client successfully made a request and received an HTTP response. By default curl does not treat that status as a transfer failure. The fail option can produce a command error for the lab's 404. I would read both the command status and the response details when checking a site.
Check your understanding
1. A file exists on the EC2 instance. What is still needed for a visitor to receive it over HTTP?
A. An appropriate listener and a site mapping that serves the resource
B. A filename extension with capital letters
C. A more recent terminal prompt
Answer and reasoning
A. The visitor needs a connection to a program that can handle the requested name and path. A local file listing cannot establish that mapping.
2. The page request succeeds and the separate stylesheet returns 404. Which test helps next?
A. Restart every process on the instance.
B. Check the stylesheet's URL and active site mapping.
C. Count the lines in a different document.
Answer and reasoning
B. Inspect the specific resource whose request failed. The main page's response already supplies separate evidence.
3. Which response concerns a conditional reuse of cached content?
A. 404
B. 503
C. 304
Answer and reasoning
C. The server's validation response lets the client use its stored representation under the right conditions.
4. Which curl result is expected for the lab's missing file with the fail option?
A. Exit status 22
B. An HTML success message
C. A package installation prompt
Answer and reasoning
A. The option turns the observed HTTP error response into a command failure for this test. The HTTP status and shell status are separate measurements.
5. Which observation shows a proxy did not receive its needed response in time?
A. A 304 from a conditional request
B. A 504 from the gateway
C. A 200 with a known static page
Answer and reasoning
B. Use the timing and upstream logs to find where the request waited. The status describes the proxy's inability to complete that request in time.
Revision cards
Machine and listener
A web server is the program that listens and responds. Verify the intended address and port, then ask which site and path it selected.
One page, several requests
HTML can ask the browser to fetch styles, scripts and images. Check each required resource under its own URL and media type.
Static or dynamic handling
A static mapping can read a file. A dynamic handler may execute application logic or forward to an upstream. Verify the actual route.
Status narrows the problem
Use method, hostname, route, status, content and logs to locate the next check. A status describes one request at one responder.
Separate transfer and HTTP result
A command can transfer a 404 response successfully. Check its options and status, and read the actual HTTP result.
Conditional requests
A 304 can let a client reuse a stored response after validation. Check which representation and validator were involved.