Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)
7.14 Troubleshooting static sites
Don't worry if you see errors here – every student gets them. What matters is fixing them calmly, one check at a time.
इथे errors आले तर काळजी करू नका – प्रत्येक स्टुडंटला येतात. महत्त्वाचं आहे ते शांतपणे, एक एक चेक करून सोडवणं.
यहाँ errors आएँ तो चिंता मत करो – हर स्टूडेंट को आते हैं. ज़रूरी ये है कि उन्हें शांति से, एक-एक चेक करके सुलझाओ.
| Symptom | First useful check |
|---|---|
| Browser times out | Compare approved address and port, actual listener, route and applicable AWS and guest rules. |
| Connection refused | Inspect the listener address, port and service on the assigned machine. |
| Packaged welcome page | Send a known named request and inspect the parsed vhost group. Keep the required default. |
| 403 from the intended site | Check its directory and authorization rules, worker access, ordinary traversal and any relevant SELinux event. |
| 404 from the intended site | Compare the exact URL and capitalization with its selected document root and release manifest. |
| CSS or images missing | Read the actual resource URL, response status and media type in the browser network panel. |
| 502 from a gateway or proxy | Identify the response source and compare the approved upstream route and logs. |
| Configuration change has no effect | Check whether the relevant file was included, validated and adopted, then compare the exact request. |
| Old destination after stop/start | Check the assigned instance's current address and the name's actual DNS answers. |
| Address already in use | Identify the current socket owner and choose a dedicated test listener or host if needed. |
Golden troubleshooting commands:
# Confirm the intended listener. Use the assigned site name in the full lab.
sudo ss -ltnp
# Read only the logs for the configured site and its actual service.
# Inspect a mapped public path on Linux:
namei -l /var/www/class-notice-lab/timetable.html
Inside works, outside doesn't?
If curl http://localhost works on the server but the browser cannot open http://<PUBLIC_IP>, the problem is outside the web server: security group, firewalld, NACL, public IP, or you typed https.
Ravindra Bagale's Tip
Many students change three things at once when a problem comes up, and then never know what fixed it. One change, then test, then the next change. Start with a named GET request through the assigned local listener. Compare its status and body with the same intended request through the approved client path.
Ravindra Bagale's Tip – मराठी
खूप students problem आला की एकाच वेळी तीन गोष्टी बदलतात, आणि मग कशाने fix झाला ते कळतच नाही. एक बदल, मग test, मग पुढचा बदल. आधी ठरलेल्या local listener वर site चे hostname वापरून GET करा. Status आणि body बाहेरच्या मंजूर client वरून त्याच request शी तुलना करा.
Ravindra Bagale's Tip – हिंदी
बहुत students problem आने पर एक साथ तीन चीज़ें बदल देते हैं, और फिर पता ही नहीं चलता कि fix किससे हुआ. एक बदलाव, फिर test, फिर अगला बदलाव. पहले तय local listener पर site के hostname से GET करो। Status और body को मंजूर client की उसी request से तुलना करके देखो।
Lab
Chala, khalcha local lab kara. HOME page ani nested page la 200 milala tari CSS request 404 deu shakto. Tya resource cha exact URL tapaasa. Fakt link badla ani CSS la 200 milato ka te paha. Parat homepage suddha tapaasa.
Investigate a static site by changing one thing at a time
A centre that offers evening classes has an announcement page on an EC2 instance. One student says the site opens from the server but not from a laptop. A second says the correct homepage opens, but its timetable link yields an error. A third sends a screenshot of a different welcome page. Those reports sound like a single hosting outage until you ask for the exact URL and response in each case. Good troubleshooting starts by finding the smallest failing operation and a closely related operation that still works.
In this lesson you will trace a client connection to a named server block and then to its public files. You will distinguish a client networking error from an HTTP response, identify which virtual host handled it, and compare the mapped path with your approved release. We will also examine browser-only symptoms such as CSS or cache problems. The exercises use either read-only evidence on your own assigned host or intentionally flawed files in an isolated loopback service. They require no interruption to an existing site or changes to a production security group.
Choose one request before starting. Write down its scheme, hostname, port, path, client and time. Mark the expected status, page marker, and whether any redirect is expected. Save the exact symptom rather than “website broken”. Then make one bounded change that addresses the strongest evidence, repeat the same request and compare the result. If a previously working control request now fails, stop and reconsider that change. Repeatability makes the source of the problem clearer and makes rollback verifiable.
Record the result from both the reader and the origin
The reader's browser tells you what their actual path produced. Use its network view to find the request that failed. Record the final URL, status or error, any redirect and whether the response depended on a cached resource. The browser address bar alone can hide changed schemes, asset requests and intermediate redirects. If the URL involves credentials or sensitive query values, collect a sanitized path and the relevant symptom rather than sharing the entire request.
A direct probe from inside the assigned server is a second view. Choose the intended host name and local address or internal network path for the actual listener. A request to localhost alone can select the default site, and a HEAD-only request reports no content. This lesson uses GET and asks curl to show the headers and the body for a synthetic sample. The content marker helps you compare the correct site with a generic default that also returned 200. A per-request override can preserve the desired host while fixing the destination for one controlled comparison.
# Adjust for your approved local HTTP listener and sample hostname.
SITE='class-schedule.example.test'
curl --noproxy '*' --resolve "$SITE:80:127.0.0.1" \
--silent --show-error --connect-timeout 3 --max-time 8 \
--include --write-out '\nhttp=%{response_code} address=%{remote_ip}\n' \
"http://$SITE/timetable.html"
printf 'curl exit code: %s\n' "$?"
Here the inclusion option prints the HTTP headers with the response body so both can be inspected in order. The write-out string reports the HTTP status if a response was received and the remote address curl observed when available. A curl exit code describes the client command's execution; without a failure-on-HTTP option, curl can return a successful exit code after receiving a 404. That is expected because it succeeded in retrieving the response. The HTTP status is another number with a different meaning. Read both when deciding where the fault lies.
For a true outside-path check send the same host and resource from an approved client through the normal public or private delivery route. A test that changes the scheme or hostname simultaneously can give a different outcome for legitimate reasons. A test with --resolve exercises the mapped destination only for that command; it does not prove the actual public DNS answer is correct. When comparing the server and reader's paths, keep the exact request details identical where possible and identify each deliberate difference in your notes.
Separate name resolution, socket access and HTTP status
If curl cannot resolve the hostname, there may be no connection to inspect. Compare the expected DNS records with the actual resolver output, using dig or another supported lookup. A valid A record lists IPv4 data while an AAAA record supplies IPv6 data. A client can choose a different address or family than the one you tested locally. A recently changed address can also still be cached. The site's hostname might be correct even if the connected server differs. Record the observed destination whenever the command can report it.
If an attempted connection is refused, the client received a refusal while trying to establish it. An inactive service or a wrong port is a common explanation. A firewall or other component can also reject connections. If it times out, the network or server did not respond to some operation before the deadline. An incorrect address, unpermitted inbound route, nonresponsive service or network problem can contribute. A timeout alone does not identify a specific firewall or security group. Compare a local attempt, the listener state and the approved route before deciding what to change.
sudo ss -ltnp
systemctl is-active nginx
systemctl is-active apache2
systemctl is-active httpd
On Linux ss shows the actual listening TCP sockets. Run the service command for whichever service the lesson uses. Check addresses as well as ports. A process bound only to loopback can respond from the server and still be unavailable from another host. A wildcard IPv4 listener behaves differently from an IPv6-only binding. A listener on 443 requires a compatible TLS setup, and a port can also be used by a service other than the one you expected. The process identity and unit state keep those possibilities separate.
HTTP status tells you about an exchange that did reach an HTTP endpoint. A 200 reports a successful response for that endpoint, but the returned content might belong to another vhost or cached release. A 403 is a refusal to fulfill the request. A 404 represents a missing resource or another configured missing response. A 502 from a gateway or proxy indicates a problem with the response it got from an upstream server; that does not necessarily mean the upstream process is stopped. A purely direct static site does not involve the same application backend path. First identify which layer returned the status.
Use the approved route to explain differences between clients
Suppose the named local request returns the exact evening timetable marker. A permitted reading room computer gets a timeout. This outcome supports looking first at the delivery path. It does not show whether the other client connected to the right socket. Compare its destination address and requested scheme, then verify that the active listen address can accept traffic from that route. For a direct public EC2 test, inspect the assigned public address association, eligible route to an internet gateway and applicable network rules. For a private client, inspect the approved private connection instead.
An EC2 security group and a host firewall can both influence delivery. A security group is applied to the network interface for connections in scope. A guest firewall makes a separate decision at the instance. Network ACLs and routing also contribute where applicable. Compare existing states and identify the authorized source and port. A successful local request can bypass the path you are investigating. Fixing that path might require the infrastructure owner, and a new broad inbound rule would provide little explanation without the original comparison.
Do not assume an automatically assigned public address survives every stop and start. The EC2 console or approved metadata tools can report the current associated address. A changed address could make a previously correct DNS answer or saved URL point elsewhere. An Elastic IP is an optional stable public IPv4 path, while a managed front door can provide another stable endpoint. With a consistent DNS hostname, the site's server_name or ServerName need not change merely because the endpoint address does. Verify the hostname after adjusting its approved destination.
Try a normal, verifying HTTPS request if that is the reader's actual URL. A certificate exception occurs before the protected HTTP request can use the site files. Inspect the certificate name, chain and service path, then the HTTP response once TLS succeeds. For a plain HTTP laboratory keep that scheme explicit. An automatic browser upgrade can otherwise make a valid local HTTP test seem inconsistent with a failing HTTPS visit. Make a separate acceptance line for each scheme you intended to support.
Read a client error and an HTTP status as separate fields
When there was no accepted HTTP response, a curl write-out can print 000 and the client can return a nonzero exit code. The digits 000 are an indication from the client display here, rather than a status code sent by the expected site. A resolver error names the host that could not be resolved. A connect error can name the address and port. A TLS exception describes a later failure, after a connection was attempted. Record both curl's actual error text and which phase executed successfully. The same display value can appear for several failures.
A total request timeout also needs context. With a short connection deadline and a separate overall deadline, the client may connect and later wait too long for a response body. A site can have accepted the request and logged it while curl reports a timeout from that later wait. If the output includes response headers, read them. If it includes a connect timing, match it to the socket and log evidence. Reducing the timeout can make a test more convenient, but choosing it unrealistically low can confuse normal latency with an actual delivery problem.
If you later add the --fail option to a scripted health check, HTTP error responses can also make curl exit unsuccessfully by design. That is useful when a pipeline needs to require success. For first-line investigation leave the raw status and body visible, especially when a custom 404 could establish you reached the correct vhost. Capture the exact command options along with the result. Two operators can get different exit codes for the same server response because their client's definition of command success differs.
Determine which site received the request before moving files
When the expected browser shows a packaged welcome page, record its status and body marker. A 200 shows that something responded. Test the intended host value rather than the bare address, and compare the per-site access log. The requested name and port may not match the named site. Configuration can be staged in an available directory or a misspelled include location and parse correctly without being loaded. Inspect the complete selected configuration on the expected service to find the matching name, port group, root and source file.
# Use only the commands for the assigned server and operating system.
sudo nginx -t
sudo nginx -T
sudo apache2ctl configtest
sudo apache2ctl -S
sudo httpd -S
Nginx's full output includes file markers. Find the source of the relevant server block. Apache's site mapping output is useful for the address and port group and the effective fallback. Keep a copy of the before-state for anything you plan to change. A duplicate name, different listen group or byte-for-byte duplicate root can give misleading body results. Even a config dump only confirms what its command parsed from disk. After validation and the approved reload, send the same request to see what the running process actually adopted.
Keep the intended default available. Removing it changes the behaviour of unmatched hosts and may affect another site without repairing the expected named mapping. Compare an explicitly assigned named request and a deliberate unmatched request against the baseline. If the correct request still lands in another log, compare the request hostname, the listener group and any intermediary forwarding rules. Work on the selection rule first. Moving the expected HTML directory will not redirect an incorrectly selected vhost to it.
Read the mapped path, access policy and error record
Once you have identified the intended site, inspect its document root and directory rule. Work out which local path should correspond to the URL. For example, a vhost rooted at /var/www/class-notice-lab normally looks for /var/www/class-notice-lab/timetable.html at the chosen path. A separate alias, location rule or rewrite could change that mapping. Read the configuration that selects this URI before assuming the simple path applies. The release file listing should establish what was really uploaded to that root.
ROOT=/var/www/class-notice-lab
ls -ld "$ROOT"
namei -l "$ROOT/timetable.html"
find "$ROOT" -type f -print | sort
The last command shows files in that owned root. A spelling difference such as uppercase Timetable.html can work during a local review on a case-insensitive filesystem and lead to a different result on the CentOS, Amazon Linux or Ubuntu server. An extra upload directory can have a similar effect. Correct the file's placement or the intended URL reference based on the approved manifest. Check a control file already served from that root so your evidence shows the active site and the particular path still behaving as expected.
A 403 can be the intended response for an existing directory without an allowed index or listing. It can also arise from authorization or readable-file access. A directory mode and file mode govern separate actions. The worker needs traversal through each ancestor and the ability to read the selected bytes. If host policy such as SELinux applies, inspect the runtime process and relevant actual and expected file contexts. A scoped file or path correction can answer the observed problem. Recursive ownership and global policy changes can hide the cause and affect unrelated resources.
Choose the log source for the question you are asking. A site-specific access log can show a request and its status. Its error log may identify the path or rule involved. The service journal is more relevant when starting or reloading failed before requests could be accepted. Missing entries are ambiguous until you know which logging scope, time and buffering options apply. Check the active configuration's log settings. Use only the necessary request lines from your test when reporting evidence, because system logs can contain unrelated details.
# Example for an approved Nginx lab with these configured log paths.
sudo tail -n 15 /var/log/nginx/class-notice-lab.access.log
sudo tail -n 15 /var/log/nginx/class-notice-lab.error.log
sudo journalctl -u nginx --no-pager -n 18
For Apache on a typical Ubuntu host, look under the configured Apache log directory commonly found at /var/log/apache2. On the common RPM setup it is often /var/log/httpd. Site-specific overrides may select other paths. If a shell command cannot find a file, compare the configured error or access directive rather than assuming all server errors are absent. Cross-reference the precise probe time and requested path before drawing a conclusion from a log line.
Diagnose a correct HTML page with missing styling or images
A browser gets the page and then requests resources named in it. A successful status for HTML is only one of those exchanges. A CSS link such as css/site.css is relative to the document's URL path. From /courses/intro.html it points to /courses/css/site.css. If the release puts its CSS at /css/site.css, that relative reference selects a different path. A leading slash can fix the sample when the site uses the entire host root. A site intentionally hosted under a URL prefix needs an appropriate base or link path for that deployment.
Open the browser's Network panel and reload the affected page. Locate the stylesheet and image requests. Click the bad request to inspect the full URL, status, media type and any redirects. A stylesheet response can have status 200 and still be wrong if its body is a generic HTML fallback. The content type tells you how the server identified the response. Check that the chosen CSS marker is present, and confirm the browser console does not show an interpretation or content policy error for that URL.
A stylesheet can have the intended type and still produce the old design if a cached response or different release is in use. In an approved diagnosis, compare browser network information, Cache-Control and other response headers, and a fresh direct request to the expected origin. Configured intermediaries can serve cache entries independently of a browser. Disabling the browser cache for a temporary inspection does not remove every shared cache. If the direct server and browser path produce different bytes, identify the active delivery path before asking for a cache reset or reissuing files.
A CSS or image URL might also use plain HTTP inside an HTTPS document. A browser can enforce a mixed-content policy for that resource even though the top-level certificate was accepted. Check the failed URL and the console reason, then update the owned reference to the approved secure endpoint or same-site path where appropriate. When the exact resource request returns its expected type and bytes through the actual delivery route, reload and check the render again.
Identify a stale response without clearing every cache
Imagine the evening programme changed a stylesheet after rehearsal. One learner sees the new heading but old colours. Another opens a new curl process and gets the new CSS marker. Compare the exact requested asset URL and its response headers before changing anything. The browser network panel may identify a cached resource or a validation response, while a direct curl request can establish which bytes that client currently receives from the tested service. If a front door and direct origin use independently cached objects, exercise each through its intended approved path.
A 304 response can appear when a client sends a conditional request and the server indicates it may reuse its stored representation. In that exchange the body can come from previously retained data. This is different from downloading a new stylesheet with status 200. Compare the clients' URLs, conditions and expected body version before filing a content mismatch. A browser-only cache bypass can help you compare one session, but it does not republish a file or refresh every other client. Check the chosen production cache policy with the site owner before changing it.
Keep a controlled single-file remedy where possible. A stylesheet naming convention with explicit release identifiers can help clients distinguish versions when the owners plan versioned assets. The associated HTML must point to the intended filename, and old versions can still be needed by earlier documents. Check both page and linked asset before removing an old copy. An arbitrary global purge or changing the site root will not correct an HTML reference that still names the former stylesheet. Use the difference between observed body and requested path to choose the remedy.
Interpret a failed start or reload without stopping an unrelated daemon
A bind error can say that an address and port is already in use. Confirm the listening process and local addresses using ss. Check both IPv4 and IPv6 bindings when applicable. The process could belong to a different site or an already running instance of the same web server. Keep it available while its owner reviews the planned change. An isolated practice listener on a high local port or a separate machine can test the candidate with no ownership conflict. Starting or enabling a different daemon is unnecessary to prove the file mapping.
When changing configuration in a managed service, review the relevant candidate and its include first. Validate the whole selected configuration with its appropriate test. If a syntax error appears, inspect the reported file and line and fix the candidate before reloading. A currently healthy process may still use its loaded settings even when files now contain an error. Keep a copy of the intended prior state so the service can later restart or reload successfully. Check service logs after activation and repeat the exact HTTP probe.
A syntax success may include a warning about a duplicate name or another best-effort condition. It may also ignore a candidate that is outside the include path. Check the vhost list or expanded input rather than using the last line alone. Conversely, an active unit check describes process state and says little about the requested vhost and public file. Parse, activate and accept are useful separate steps. Restore your own precise previous file or link if the new activation fails the comparison.
Lab one. Reproduce and repair a missing stylesheet in a temporary site
This lab needs Python 3 only. It stages a homepage, a nested information page and a stylesheet in a new temporary directory and listens on an ephemeral loopback port. The nested page intentionally uses the wrong relative CSS link. You will see the expected HTML and then an independent 404 for its style. The program changes only that one reference and repeats the same checks. It performs no external HTTP request and never uses any real web root.
python3 - <<'PY'
from functools import partial
from html.parser import HTMLParser
from http.client import HTTPConnection
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from tempfile import TemporaryDirectory
from threading import Thread
from urllib.parse import urljoin
class TrainingRequest(SimpleHTTPRequestHandler):
def log_message(self, format, *args):
pass
class Asset(HTMLParser):
href = ""
def handle_starttag(self, tag, attrs):
values = dict(attrs)
if tag == "link" and values.get("rel") == "stylesheet":
self.href = values.get("href", "")
with TemporaryDirectory(prefix="site-triage-") as area:
root = Path(area)
(root / "css").mkdir()
(root / "courses").mkdir()
(root / "index.html").write_text("<h1>Evening classes release</h1>")
(root / "css/site.css").write_text(".evening { color: navy; }\n")
child = root / "courses/intro.html"
def write_page(sheet):
child.write_text(f'<link rel="stylesheet" href="{sheet}">'
'<h1>Course introduction</h1>')
handler = partial(TrainingRequest, directory=str(root))
with ThreadingHTTPServer(("127.0.0.1", 0), handler) as web:
t = Thread(target=web.serve_forever, daemon=True)
t.start()
def get(path, method="GET"):
connection = HTTPConnection("127.0.0.1", web.server_port, timeout=3)
try:
connection.request(method, path)
response = connection.getresponse()
return response.status, response.getheader("content-type"), response.read()
finally:
connection.close()
def asset_check():
page_url = "/courses/intro.html"
status, media, html = get(page_url)
assert status == 200 and b"Course introduction" in html
parser = Asset()
parser.feed(html.decode())
asset_url = urljoin(page_url, parser.href)
asset_status, asset_type, asset_bytes = get(asset_url)
print(f"{page_url} {status}; {asset_url} {asset_status} {asset_type}")
return asset_status, asset_type, asset_bytes
try:
assert get("/")[0] == 200
assert get("/", "HEAD")[2] == b""
write_page("css/site.css")
assert asset_check()[0] == 404
write_page("/css/site.css")
status, media, css = asset_check()
assert status == 200 and media.startswith("text/css")
assert b".evening" in css
assert b"Evening classes release" in get("/")[2]
print("control homepage still serves its intended body")
finally:
web.shutdown()
t.join(timeout=5)
PY
The first asset URL should start with /courses/css and return 404. The corrected one should start with /css and return 200 with CSS bytes. Both document requests can return 200. The explicit HEAD check demonstrates it carries no response body for the control path. The script then checks that the approved homepage stayed correct throughout. If you choose to reproduce this in a browser with your own local fixture, use a specific loopback URL to the nested document and compare the reported resource path in the Network panel.
The script stops its own temporary service and its directory is automatically removed. If the CSS correction causes a different result in an exercise variant, look at the link value parsed from the returned HTML. The root-relative path fixes this particular host-root publication, while a different deployment prefix would call for its own intended URL. This difference is the lesson: the server chooses a file only after the client has chosen exactly which URL to ask for.
Lab two. Compare one authorized site from two permitted clients
Use a training site you administer, an expected file marker and a client that is already permitted to request it. For this inspection do not alter existing access rules. Confirm what the normal route should be. A site can be intentionally private, and a public browser that cannot reach it may be following the expected policy. Record whether the permitted client connects directly to the instance, through a private path or through a managed front door.
Choose one named status check and one failing path. For the initial control use the known homepage or a marked release file. Record the traffic scheme, the intended host and the exact URL path. Verify the guest identity and the running service name.
Inside the guest, request both files using the expected local binding and site hostname. Record the status and body marker, then read the appropriate current access or error log. A failed request can be an intentional 404. The control confirms whether the chosen listener can serve at least one resource from the expected vhost.
Repeat both requests from the approved outside client along the normal route. Identify its address family and actual destination when available. Keep the URL name and path consistent. When the exercise uses HTTP and HTTPS independently, report them as separate tests rather than merging their results.
Compare what the site recorded at the corresponding request times. If the outside request reached a separate front door, check that layer's evidence as well. Use the chart below to choose which record to read next. Keep the other path as a control before approving an edit.
A passing run has two interpretable results: a verified origin response and the expected outcome along the permitted route. On a private lab the two checks can be loopback and a private client. There is no requirement that either test pass from an arbitrary outside network. When the client reaches the expected site but one file is absent, the next job is to compare mapping and release bytes. When the outside client never connects, examine the destination and network path before altering a site file. Record any approvals needed for a real correction.
The comparison creates only ordinary diagnostic requests and any local notes you decide to save. If you staged a temporary response file outside the served tree, remove that exact file when you are done. Keep authorized logs and change records according to the training plan. A real remediation should be scoped to the confirmed cause and verified by the same two clients. Do not change an existing rule solely to manufacture a failure for this lab.
Classify the failing exchange and pick one useful next check
| Observed symptom | Compare next | Likely decision point |
|---|---|---|
| Unknown hostname before a connection. | Inspect the client's resolver result and the approved name assignment. | Address selection. |
| Connection refusal or timeout. | Check actual listener, approved destination, source and route. | Socket access or network delivery. |
| Invalid or unexpected certificate. | Check the URL identity, endpoint and served trust chain. | TLS handshake. |
| Successful HTTP response from an unexpected default. | Use the correct host and inspect the eligible vhost group and log. | Site selection. |
| 403 for a known path at the intended site. | Check site rules, real file and directory access and host policy evidence. | Authorization or path access. |
| 404 for a specific named site's file. | Check exact URL spelling, root and release manifest. | File mapping or missing-resource policy. |
| HTML works and a resource looks wrong. | Inspect the browser resource URL, media type, body and cache view. | Asset lookup, browser resource policy or release consistency. |
Apply this to a request for /timetable.html that returned 404 at the correct vhost. A log says the process did not find the expected path, but the administrator finds /var/www/class-notice-lab/release/timetable.html. Compare that extra release folder with the configured root. The hostname and permissions might already be fine. If all approved files belong to the inner release, pick the correct deployment root or place the approved files at their intended positions based on the site's release process. Then repeat the exact same named probe and test one asset path.
Another report says a web server failed to start after a candidate was added. The first journal message says the configured bind address is already in use. Check which process owns it before touching any file modes. If it is the existing service for another project, leave ownership intact and test the candidate on an isolated listener. If it is the expected service and the reported error comes from trying to launch a second copy, check whether the right operation was a managed reload. Reading the first useful error prevents correcting an unrelated configuration file.
When a colleague shows a 502, identify whether an upstream is involved before changing the server. A reverse proxy can generate it because it failed to establish a suitable upstream connection or got an invalid response. Log details and the approved backend status matter. The public web server can be active and still have an upstream failure. A pure file route under the same server might continue to work. Compare one intended direct static asset with an affected proxied route so you know which portion of the deployment needs attention.
Choose a control that shares the part you want to test
If the timetable fails, a working site on another machine offers little information about the failing path. A better control is a known page from the same hostname and server block, close to the affected file. It shares hostname, network path and broad site rules. If the problem is the client network itself, the local named counterpart is useful because the two requests intentionally differ in delivery but expect the same content. Pick the control to match the question.
Produce a diagnostic report another learner can reproduce
Keep a short record of the pair of requests, expected results, actual results and one source of supporting evidence. For example, “On the assigned guest, named HTTP GET /courses/intro.html returned 200 with the expected title. The stylesheet requested at /courses/css/site.css returned 404.” This is actionable because the second observation identifies the missing path. A screenshot of the unstyled page can illustrate the issue but cannot show whether the resource failed to load or returned the wrong bytes.
After a single correction, repeat the exact checks. Add the new CSS URL, media type and status. Keep the unchanged successful homepage as a control. If the original failure was a timeout, report when the connection succeeded and what changed along the approved route, without assuming every reader now reaches it. If your change involved an authorized scope outside the website directory, include who owns it and how to revert it. Store evidence in an allowed place and avoid exposing secrets, full requests or records from other sites.
Use the same discipline for rollback. Restore the exact prior file or config from the approved backup, verify syntax when relevant and test its known marker and required routes. If rolling back fixes the control and the original expected route, report that outcome and the remaining uncertainty about the failed candidate. A rollback returns service to a known state. It does not determine the failed mechanism by itself. Keep the candidate and comparison evidence outside the active include or public tree when its owner needs to examine it later.
Interview questions with explained answers
How do you start investigating “the site is down”?
Ask for one exact request, time, client, expected body and observed result. Choose a matching local or approved comparison and identify whether the failure occurred before TLS, during site selection or after the request mapped to a file.
What does a successful request to localhost prove?
It shows the chosen local socket responded to that request. Use the expected hostname and body marker to make it evidence for the named site, then test the actual reader's approved route separately.
Why can 403 and 404 require different checks?
A 403 can indicate a policy or directory representation decision. A 404 can indicate a missing mapped file or deliberate missing response. Read the intended site's actual path, log and relevant access context to distinguish causes.
Why can a configuration test pass with no visible effect?
The candidate might be outside the include, the warning might identify an ignored name, or the running process might still use previous settings. Check the parsed site map and test the exact host after approved activation.
How do you diagnose an unstyled page?
Find the actual stylesheet request in the browser network view. Compare its URL, status, content type and body with the approved asset. Check redirects, mixed content and cache if the browser and direct source differ.
Check your understanding
Curl exits successfully and prints HTTP 404. Can both statements be true?
Show answer
Yes. With its normal behaviour curl completed the HTTP exchange successfully. The server's separate status reports that the requested resource was missing or treated as missing.
The correct named local page works and a permitted outside client times out. Which paths should you compare?
Show answer
Check the client's destination, address family, service binding and approved routing and traffic controls. The successful local read covers only the local delivery path.
The homepage gives 200, but the stylesheet request also gives 200 with HTML. Did the design pass?
Show answer
The browser needs the stylesheet bytes and a usable CSS media type. Check the file path and any fallback that returned HTML at that URL.
Another program is bound to the socket for your proposed service. What first preserves the existing site?
Show answer
Identify the process and owner. Use a separate authorized test environment, then coordinate any real service change under that owner's plan.
Why keep a control request after fixing one file?
Show answer
The control shows that an existing expected path still works while you retest the repaired path. It helps detect a broader unintended change.
Practise interpreting the result before choosing a repair
Write a two-request comparison for the HTML and missing CSS from the loopback lab. Include the URLs the client derived and the expected type before and after the correction.
Make a plan to investigate a wrong welcome page without editing the default site. Include named request, effective vhost map and one access log comparison.
Classify a sample report as connection, TLS, vhost, mapping, access or asset issue. Write down the strongest evidence for that classification and one check that could disprove it.
Revision cards
- Exact request
- Identify scheme, destination, name, path, time and client. These details make two responses comparable.
- Transport evidence
- A resolver or connection problem happens before the expected HTTP response. Inspect the path and listening socket.
- HTTP evidence
- Status, media type and body provide different facts. Know which virtual host handled them.
- Directory and policy
- Check mapped path, ordinary traversal, application controls and any host enforcement before modifying permissions.
- Browser resources
- The browser makes separate requests for assets. Test the real asset URL and type from the network view.
- Controlled correction
- Change one supported cause, repeat the failing request and keep a known-good control before declaring the fix.
Official sources
- HTTP semantics and status codes
- HTTP caching semantics
- Curl tests, exit codes and options
- Linux socket inspection
- Filesystem path traversal inspection
- AWS internet gateway and route requirements
- AWS VPC security groups
- EC2 public IPv4 and Elastic IP behavior
- Nginx site selection
- Nginx request log context
- Apache virtual host matching
- Apache access and error logs
- systemd journal inspection
- Chrome network request inspection
- SELinux denial investigations
- Python local HTTP handlers