Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 6: Web Servers — Nginx and Apache

AWS Cloud

Common Mistakes I See Students Make

Friends, I see these web server mistakes in every batch – two servers on port 80, forgetting to reload, the wrong web root. Read them once; later it will really save you time.

  • Starting two independent servers on an overlapping address and port can make the second bind fail. Identify which process already listens before making a change.
  • Editing a site configuration and forgetting to apply it can leave the current route unchanged. Confirm the edited file is actually included and test it before applying.
  • Copying content to a guessed document root can leave the selected site serving another directory. Trace the named request to its effective root or alias.
  • Assuming unit names are universal can send you to the wrong service. Apache commonly uses httpd on Amazon Linux and CentOS Stream and apache2 on Ubuntu.
  • Disabling SELinux to bypass an unexplained refusal changes policy broadly. Check the actual denial, filesystem access and configured label first.
  • Adding Apache directive comments on the same instruction line can make the candidate invalid. Put them on a separate line.
  • Omitting an Nginx simple directive's delimiter can make parsing fail at that or a later line. Inspect the reported context and preceding instruction.

Use the symptom to choose the next check

When a listener fails to start, identify the exact local address, port and owner. When the wrong site answers, use the intended hostname and compare a recognizable response body. When only one file fails, calculate the path from the selected root or alias and check the diagnostic. When only a proxied route fails, compare the actual target and protocol to the backend's documented listener.

Keep the working site intact during diagnosis. A local HTTP check and a request through the intended named public route answer different questions. The exercise below isolates the fallback, missing file and failed proxy responses so you can compare direct evidence.

Turn a vague report into a testable request

Friends, suppose a training centre's help desk receives the message, “The website is down.” One student opened the homepage successfully. Another followed yesterday's handout link and saw an error. An instructor on the local network opened the correct page, while someone using the public address received a certificate warning. All these reports can be true. The word website hides several distinct requests. Before changing anything, ask for the exact address, time, observed result and intended result. This can turn a broad outage report into a specific problem with a particular name, connection, path or backend.

Collect enough information to replay a simple safe request on a system you are authorized to diagnose. Record the scheme, address or name, port if it is shown, and path. The scheme is the part such as HTTP or HTTPS that tells the client how to connect. A host is the name or IP in the address. The path names a resource or route within the selected site. If the user is logged in, record whether the failure requires an authorized account without collecting credentials. If the failing operation would make an order or change data, choose a safe probe first and coordinate any reproduction that could change state.

Write the expected evidence before testing. A status of 200 and the text Saturday handout are a stronger expectation than “the command works.” A 302 and a particular destination header may be correct for a planned redirect. An intentional missing-file probe may properly return 404. A request that received an error page has already reached some component that can send an HTTP response. A browser that reports it cannot establish a connection has given different evidence. The distinction matters when choosing between a service log, a DNS check or a file lookup.

Work from one supported observation to one plausible next check. Suppose an IP address returns the package welcome page. A web server answered on that address, which is good information. The site's public name may select another server block or send the request elsewhere. Ask for the named route next. If the named homepage returns the expected marker while the handout shows 404, stop treating all traffic as unavailable. The remaining problem concerns a specific route or resource. Each good check removes a part of the problem from the immediate investigation.

When a service cannot open its listener

A listener is a local address and port where a process accepts connections. Port 80 is the ordinary default for HTTP URLs with no explicit port. Two independent services both attempting to claim overlapping address and port bindings can collide. A Nginx error mentioning address already in use indicates a binding conflict for the displayed address and port. Merely installing both Nginx and Apache is not by itself the collision. Their processes have to attempt conflicting binds. Both can be used in valid deployments, for example a frontend using one interface and port and a backend on a different loopback port.

On an authorized Linux machine, ss -ltnp '( sport = :80 )' requests listening TCP sockets whose local port is exactly 80 and asks to show process details where accessible. The process information can be incomplete when your account lacks the needed privileges. The address column matters as much as the number. A bind to the IPv4 wildcard address can overlap specific IPv4 addresses on that port. A displayed IPv6 socket may also matter for IPv4 connections depending on how it was created. Counting lines that contain the digits 80 can include unrelated ports such as 8080 and miss this distinction entirely.

Keep the running frontend until you know what owns it and how traffic should be routed. It could be a long-running production service, or a process published through a container manager. A service named nginx is one possibility, but a different owner can hold the expected port. When you do not own it, record the address, port, process details you can see and competing start attempt. Hand that ownership information to the appropriate person. For your own lab, choose a fresh loopback port and configure the intended client to use that explicit port.

For example, an instructor starts an Apache exercise while Nginx already serves the course. Apache reports that it could not bind 0.0.0.0 port 80. The instructor checks the listening socket and sees the existing frontend's identity. A better design is to make the exercise an independent loopback instance on an assigned high port, with a distinct config, root and log, then test it directly from the same machine. Turning off the course frontend for an unrelated exercise could make the course unavailable and hide what the original binding error was protecting.

If the expected listener is missing, use the installed package and unit definitions to identify how the service is supposed to start. On the named RPM-based teaching platforms the Apache service is commonly httpd.service. On Ubuntu it is commonly apache2.service. A unit-not-found report may be explained by using the wrong name, not installing that package, or running inside an environment with a different supervisor. Read availability and unit status before starting anything. The service under review may also be managed by another process, so compare the listener with the unit rather than inferring ownership solely from a familiar executable name.

When the connection reaches the wrong site

A single listener can serve several domain names. A request to the IP address uses that IP as its ordinary HTTP host value, which may select a default. A browser URL with the training domain asks for a distinct name. In Nginx, the default site is determined for the listener, and its server_name line is not a magic wildcard simply because it uses an underscore. In Apache, eligible virtual hosts are selected by the listener address and port and then the name among that set. An unmatched name can select the first eligible virtual host for a shared address and port. Always verify the intended name as well as the intended socket.

In the cleartext loopback exercise below, the address and port stay constant and the host value changes. The fallback and named site both return 200, but their markers are different. A wrong site often looks like success to a monitoring check that verifies only the numeric status. Use one benign piece of visible content that proves you reached the intended handler. In a live change, that might be an approved version string or a known heading on the class page. Do not use an internal secret as the marker. It may end up in an access report or page used by everyone.

HTTPS adds a prior decision. The client and server negotiate TLS before the ordinary HTTP request is sent, and the hostname offered by the client can influence the certificate the server presents. Sending a Host header to an IP URL does not normally recreate that named TLS connection. For an authorized test of a named HTTPS endpoint at a known address use the intended hostname in the URL and a suitable name mapping if required. Keep certificate checks enabled. If the failure is a certificate name mismatch, record the expected name and selected certificate without making a request look healthy by disabling verification.

Consider a public domain with both IPv4 and IPv6 records. Your local IPv4 test reaches the named site. A different client attempts the IPv6 address and sees a fallback because that listener or public address differs. A single successful IPv4 response explains only its own path. Check both address families when the domain advertises both. Check what the client resolved, which path was attempted and whether the installed service listens on the expected addresses. DNS, routing and web configuration are each possible causes and changes to one should be justified by the observation that points there.

When the correct site cannot deliver one file

Assume the homepage now returns the expected course heading. A handout link still answers 404. Begin by comparing the path requested by the browser with the link the course published. On typical Linux filesystems, a capital letter can distinguish one filename from another. A link to /handouts/Saturday.pdf may lead to a different file from /handouts/saturday.pdf. A copied file can also have a hidden extension or live in a folder for the wrong website. Checking the exact path in the access log avoids diagnosing a file that the client never asked for.

Trace the selected location's filesystem mapping. A server block may set one document root, then a selected location or directory rule can use a different path. The common packaged location taught for Nginx on a distribution is only a starting clue. A root instruction normally combines its base with the URI. An Nginx prefix alias substitutes a configured physical location for the matched URL prefix. The error log may include the attempted path and whether the open failed. If its path points to a different tree from where you copied the file, fix the mapping decision or the deployment destination. Merely copying the file to three directories makes tomorrow's update harder to trace.

A response of 403 means a server understood the request and refused it. That does not tell you which permission check produced the refusal. An access rule may deny the URL, a directory with no eligible index may refuse listing, or a process may be unable to open or traverse a filesystem path. On a Linux directory, execute permission allows traversal for the relevant identity. Read permission can be relevant to listing names. An ordinary readable file does not help if the worker cannot traverse a parent folder. Check the permissions in the context of the actual worker identity and its authorization rules.

SELinux, where enforced, adds a separate policy check to traditional mode bits, owner, group and access lists. Begin by reading the error and policy evidence using the platform's authorized process. A mode change to world-writable is a poor diagnosis and can introduce additional problems. A documented file-label default may be restored after a comparison shows why the current label is wrong. A custom content location may need an approved persistent file-context rule and relabeling. A connection prohibition may involve a different policy rule. A 403 alone is not evidence that any particular label or boolean should change.

Practice distinguishing two log messages. A message saying an attempt to open one precise file failed because it does not exist points toward naming or mapping. A message saying permission denied calls for examining worker access and the corresponding policy checks. The status displayed to the client may be rewritten by an error handler or gateway, so the server's own access and error evidence may be more specific. Compare a known good nearby request on the same host first. If both fail, a shared rule could be involved. If only one fails, its filename and path are a better starting point.

When the site serves yesterday's result

A saved config change does not necessarily change a running web server. The file might not be part of the effective configuration. An authorized reload may be required for a setting change, and a reload can fail or target a different service. A saved content file has different handling because a simple static route normally reads it without a config reload, although caching or deployment arrangement can affect what is observed. Ask whether the exact changed object was a setting, a public file or backend application content. Restarts are unsuitable substitutes for knowing which part changed.

First compare a named and bounded GET with the expected before and after markers. If you have a local authorized path to the server, compare the origin response with the response through the normal public route. The origin is the server that provides the response before intermediaries such as reverse proxies or caches. An origin response can prove a local route update while a frontend still serves older content. If both stay old, look at the active include, symlink or file identity and the actual apply log. Use response headers such as cache-related fields to understand what the involved component says about reuse. Their presence or absence alone does not identify every cache.

Do not forget the method. A capital I option in curl asks for HEAD and returns headers without the response body. A successful HEAD request can help verify connectivity and status, but it cannot visibly prove text changed. Use GET for the intended handout or route marker. If a monitor follows redirects, capture the original response separately so you know whether success comes from the intended route or a fallback destination. If your local GET tests a different path, you have tested a different operation even if hostname and port match.

A helpful note might say: “The candidate passed validation at 14:05, the service's log shows a reload at 14:06, the named loopback GET returned the new marker, and the normal public route returned the previous marker.” That handoff gives the next operator a good reason to compare intermediaries. Saying “I ran the reload three times and it still does not work” records effort but little context. Before repeating a command, ask what a repetition would prove that the first observation did not.

When the frontend answers but a backend route fails

A reverse proxy accepts the client's request and forwards some requests to another service. The target is often called an upstream. The course homepage may be static and never contact the reporting service, while a request to the report route requires that upstream. HTTP 502 is a bad gateway response. It indicates that a component acting as a gateway did not obtain a suitable upstream response. Common situations include a refused backend connection or an invalid response. HTTP 504 indicates a timeout while obtaining an upstream response. It does not, by itself, tell you what resource took too long or which connection phase was affected.

Start by finding the frontend access entry and the related error. A refused connection points toward the target address, port, listener state or access path. A message referring to a missing Unix socket points toward a configured path and backend process. A timeout may occur during connecting or while reading, and those stages suggest different follow-up evidence. A status 502 or 504 alone does not establish that the whole backend is broken. Compare the configured target with its documented actual listener and handler, then use an authorized direct probe only if that service speaks the protocol you are using.

For a local HTTP backend, loopback is the local machine. If the proxy and backend run in different containers or on different machines, each may have its own loopback environment. A target written as 127.0.0.1 points back to the environment sending the request. That is useful where both programs share that environment and need to talk privately. It can be wrong where the app is elsewhere. Similarly, knowing the Node process is online in a supervisor does not establish which address and port it bound. Inspect the configured endpoint and compare the request with that endpoint's supported method and path.

In a PHP deployment, the web server and PHP-FPM can communicate with FastCGI over a configured socket or address. FastCGI is a protocol for passing requests to the application workers. An ordinary HTTP GET to the FastCGI port fails to test the configured protocol. Check the pool's listener and permitted access, the web server's corresponding FastCGI request handling and the appropriate process logs. For an application behind a proxy, its name and known local port are deployment details. Do not take a number from another tutorial as evidence about the service you are diagnosing.

Some operators respond to a backend error by making its listener public. A same-host design commonly intends the backend to be reachable only through the frontend. A deployment with different hosts instead needs an authorized private path between components. Check the intended network arrangement before making a listener or firewall change. If a public frontend still serves its static files while failing one backend route, that static success can help limit the action required. Preserve the working listener and treatment of unrelated sites. The lab will demonstrate a frontend route that remains 200 even after the isolated backend is stopped.

Lab that separates five responses on one port

Use a disposable Linux machine with Python 3.7 or newer and Nginx supporting the separate error log option. Run this as an ordinary local user. The script starts its own loopback HTTP backend and its own loopback frontend. Both use the local address and high ports selected by the operating system. The sample hostnames are only labels passed in test headers. The block is self-contained, so you can run it as written without preparing a configuration or changing your system service. Python's simple backend exists only for this local comparison.

Before you run it, write down your prediction for five requests. The unknown host to the homepage selects the fallback. The accepted class host selects the named site and returns a separate home marker. A missing handout reaches that same class site, but the expected file does not exist. The report request reaches the temporary backend and returns a third marker. The deliberately broken report rule points at a different reserved local port where no process is accepting connections. This gives a connection failure from the proxy without changing either the good route or the running app.

python3 - <<'PY'
import http.client
import os
from pathlib import Path
import signal
import socket
import subprocess
import tempfile
import threading
import time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

if os.geteuid() == 0:
    raise SystemExit("Use an ordinary local account for this exercise.")
subprocess.run(["nginx", "-e", "stderr", "-h"], check=True, capture_output=True)

class ReportHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        message = b"Private report ready"
        self.send_response(200)
        self.send_header("Content-Type", "text/plain")
        self.send_header("Content-Length", str(len(message)))
        self.end_headers()
        self.wfile.write(message)

    def log_message(self, format, *args):
        pass

def request(port, host, path):
    connection = http.client.HTTPConnection("127.0.0.1", port, timeout=2)
    try:
        connection.request("GET", path, headers={"Host": host})
        response = connection.getresponse()
        return response.status, response.read().decode()
    finally:
        connection.close()

with tempfile.TemporaryDirectory(prefix="nginx-mistakes-", dir=Path.home()) as scratch:
    lab = Path(scratch)
    (lab / "site").mkdir()
    with ThreadingHTTPServer(("127.0.0.1", 0), ReportHandler) as backend, socket.socket() as held:
        backend_port = backend.server_port
        held.bind(("127.0.0.1", 0))
        inactive_port = held.getsockname()[1]
        with socket.socket() as probe:
            probe.bind(("127.0.0.1", 0))
            front_port = probe.getsockname()[1]
        print(f"Frontend {front_port}, backend {backend_port}, reserved inactive {inactive_port}", flush=True)
        config = lab / "nginx.conf"
        config.write_text(f"""
worker_processes 1;
pid "{lab}/nginx.pid";
error_log "{lab}/error.log" notice;
events {{ worker_connections 32; }}
http {{
    log_format lesson '$host $request_uri $status $upstream_status';
    access_log "{lab}/access.log" lesson;
    client_body_temp_path "{lab}/body";
    proxy_temp_path "{lab}/proxy";
    fastcgi_temp_path "{lab}/fastcgi";
    uwsgi_temp_path "{lab}/uwsgi";
    scgi_temp_path "{lab}/scgi";
    default_type text/plain;
    server {{
        listen 127.0.0.1:{front_port} default_server;
        return 200 "Fallback home";
    }}
    server {{
        listen 127.0.0.1:{front_port};
        server_name classes.example.test;
        root "{lab}/site";
        location = / {{ return 200 "Class home"; }}
        location = /reports {{ proxy_pass http://127.0.0.1:{backend_port}; }}
        location = /reports-broken {{ proxy_pass http://127.0.0.1:{inactive_port}; }}
    }}
}}
""", encoding="utf-8")
        command = ["nginx", "-p", f"{lab}/", "-c", str(config), "-e", str(lab / "bootstrap.log")]
        subprocess.run(command + ["-t"], check=True, timeout=5)
        thread = threading.Thread(target=backend.serve_forever, daemon=True)
        thread.start()
        try:
            server = subprocess.Popen(command + ["-g", "daemon off;"], start_new_session=True)
            try:
                for attempt in range(25):
                    if server.poll() is not None:
                        raise RuntimeError((lab / "error.log").read_text())
                    try:
                        if request(front_port, "classes.example.test", "/") == (200, "Class home"):
                            break
                    except OSError:
                        pass
                    time.sleep(0.1)
                else:
                    raise RuntimeError("No matching private frontend response.")
                cases = [
                    ("unknown.example.test", "/", 200, "Fallback home"),
                    ("classes.example.test", "/", 200, "Class home"),
                    ("classes.example.test", "/handouts/missing.txt", 404, None),
                    ("classes.example.test", "/reports", 200, "Private report ready"),
                    ("classes.example.test", "/reports-broken", 502, None),
                ]
                for host, path, expected_status, expected_marker in cases:
                    status, body = request(front_port, host, path)
                    visible = body if expected_marker else "(error response)"
                    print(f"{host} {path} -> {status} {visible}")
                    assert status == expected_status, (path, status)
                    if expected_marker:
                        assert body == expected_marker, (path, body)
                print("\nRecent access entries:")
                print("\n".join((lab / "access.log").read_text().splitlines()[-5:]))
                print("\nRelevant errors:")
                for line in (lab / "error.log").read_text().splitlines():
                    if "missing.txt" in line or "connect() failed" in line:
                        print(line)
            finally:
                if server.poll() is None:
                    server.send_signal(signal.SIGQUIT)
                    try:
                        server.wait(timeout=5)
                    except subprocess.TimeoutExpired:
                        os.killpg(server.pid, signal.SIGKILL)
                        server.wait(timeout=5)
        finally:
            backend.shutdown()
            thread.join()
assert not lab.exists()
print("Private processes and scratch files cleaned up.")
PY

Read the line that prints the three ports and ask which connection uses each one. The frontend is the address the test client contacts for all five cases. The backend serves a small known report from its own listening socket. The third port is bound by the script but intentionally has no active listener, so the local connection attempt to it is refused. A short interval exists between the frontend port probe and Nginx taking that port. If another local process wins the port and the start fails, the script exits with the private startup evidence and cleans up its own resources. A new run reserves a new choice.

In the first two rows, a status-only check sees 200 twice. Content and host together show that the named server answers only one request. The 404 names the same correct class host as the good page, so it leads you to the specific file path. Look at the error line for missing.txt. Notice where the expected public URI was placed underneath the temporary site root. That file is intentionally absent. The config accepted the root and could serve other routes successfully. Mark the missing response as expected on your worksheet.

The working report is evidence for proxy routing as well as the backend. In the access log, the last column comes from the upstream status variable, which helps distinguish a direct site response from a forwarded one. The next report request still reached the named frontend, but its configured target is the bound non-listening port. The error line should mention a refused upstream connection, along with the selected target. Read the upstream address there and compare it with the line printed at the beginning. The healthy report path already demonstrates that a backend exists. The failed route's own target differs. Restarting the healthy backend would not repair that route.

The process argument keeps the private Nginx master in the foreground so Python can track its exact process. The cleanup logic signals only that process, waits, shuts down the training backend, and lets Python remove the private temporary files. The final message confirms the scratch path is absent. The script prints recent log lines before that cleanup so you can copy a safe excerpt into your notes. Path prefixes, timestamps and process IDs vary by run. The useful clues are the host, path, status and difference between the attempted file and upstream connection.

Reason through cases the fixture cannot reproduce

You can use the same method on paper when the machine or package is unavailable. Write four columns labelled symptom, observation, proposed cause and next discriminating test. For the known incoming hostname and unknown host, place the latter in the category where HTTP works but site selection differs. For the absent file, put the attempted disk path in the observation column. For the wrong upstream, record the labelled port difference. A useful next test can rule out a plausible competing explanation. Copying the same curl line to the next column without changing the question rarely helps.

Now add three cases. In the first, a public HTTPS test reports a name mismatch while local HTTP serves the correct content. Ask which name went into the TLS handshake and which certificate came back. In the second, a laptop times out while loopback GET succeeds. Check the intended name and address family first, then the effective local binding and authorized network path. In the third, an existing file produces a permission-denied message. Trace the exact path and worker rights, then inspect policy evidence if relevant. None of the cases requires disabling controls to document the likely next observation.

For a team handoff, describe the evidence that kept you from making an unrelated change. The fallback proves a listening server exists. The expected local marker keeps you from editing the document root when the public connection itself is missing. A working report gives you reason to compare the failed proxy target before restarting the backend. The evidence may feel slow to record at first, but short observations make a second investigation much faster. Leave speculative causes labeled as hypotheses and state the next test in terms someone else can repeat.

Follow a local success that does not reach the student

Practice an additional thought experiment. The training teacher runs a named request on the server, and the named class marker returns. A student connects from another network and sees that the connection timed out. Working on the web root is unlikely to change a connection the student could not make. First find out whether the student's name resolved and which address family was tried. The computer may be using a DNS response cached earlier. A private address may also be resolved in one environment when another environment needs a different documented name. Compare the observed answer with the intended access path before changing a DNS record.

At the destination, confirm whether the intended service binds an address reachable by that client. A loopback-only practice listener is intentionally private to the machine. A security group, subnet routing and local firewall can also restrict incoming traffic. They serve different roles. For an AWS server, security groups control permitted traffic at the attached interface or resource, and the actual public path may additionally depend on an internet-facing load balancer or routing. Host firewall rules are local on the server. Do not open rules to all clients just to make a temporary probe succeed. Record the intended client class, destination and port for the person authorized to handle that network path.

If the response begins with a TLS certificate problem, TCP connectivity exists far enough to attempt TLS, but an HTTP request may not have occurred. Do not expect a regular access line for a request that never crossed the handshake. Inspect the proper TLS endpoint and client-visible names. If the path goes through a load balancer, its certificate can differ from the backend certificate. A successful direct test of the backend says little about the frontend certificate attached to the student's route. The teaching question is which component terminated the connection, and at what stage the client stopped.

A safe completion checklist names exactly what is ready. You can say the service parsed its configuration, the intended listener is active, the named loopback test returns the required marker, and a separate authorized request through the expected public path agrees or disagrees. Add the exact cause you verified and the file, rule or holder that was responsible. This record prevents an exception such as a fallback returning 200 from becoming a false release declaration. If public access was outside the test, say which private behavior you observed and who owns the remaining verification.

One final mistake is changing several layers at once because all look suspicious. Imagine a browser returned a wrong fallback after deployment and the engineer edits a DNS record, modifies the website's file permissions and restarts the service. If the page then works, the team cannot tell which change mattered. If it stops working, three new explanations compete. Start by holding the destination constant and changing the host value for a controlled local HTTP test. Then hold host and destination constant and change just the path. In each comparison, state which single decision the changed input exercises. This approach also gives you a useful way to pair a new student with a more experienced teammate. One describes the observation, and the other predicts the next discriminating outcome before either reaches for a command.

During later verification, compare what you fixed with the legitimate intent, including one unaffected request. For example, after correcting the report route, the expected gateway error should disappear for the repaired route and the class homepage should retain its marker. If the fallback still replies when used intentionally, that is normal for the fixture. If it starts replying to the class name too, the update affected site selection. Write down old and new behavior for both paths so the reviewer can see the intended scope directly.

Explain the smallest useful next check

Two servers both want port 80. Why should you inspect the socket before stopping either process?

The relevant collision concerns overlapping local addresses and ports. Installing two packages does not prove which process owns the existing frontend listener. I would check the exact local port and process information I am authorized to read, then match it to the known site or supervisor. If a different process belongs to the intended public service, stopping it would increase the incident. I can run a private exercise on a different loopback port or coordinate an approved routing change with the owner.

What might a successful IP-only curl test miss?

It can hit a valid listener and receive the fallback site because the HTTP hostname differs from the intended domain. For HTTPS it may also negotiate with the wrong certificate context. I would compare the expected hostname and path, verify the TLS name through the proper URL if applicable, and look for a distinctive body. Getting 200 from some handler is weaker evidence than getting the intended marker from the named site.

How do you tell whether a 404 comes from a bad docroot or a bad public path?

Read the exact URI the client requested, then identify the selected site and location. Calculate the filesystem lookup for the relevant static mapping. Compare it with the error log and the deployment's actual file. If the computed base is wrong, look at the route or deploy directory. If the base is right and the final name differs, correct the link or delivered filename. When the route is generated by an app, follow its handler and the available app logs instead of assuming a local file was opened.

Which clues distinguish denied file access from an unavailable application backend?

A static-file denial may show an attempted file open with permission denied or describe an authorization rule. A proxy failure can show a connection refusal, timeout, missing socket or invalid protocol response for a backend target. The status tells me what the client received, but the selected route and matching diagnostic give the next useful check. Compare the precise request with a nearby known good one before changing permissions or restarting application processes.

The backend is online and one proxied route still returns 502. What do you ask next?

I would inspect the upstream address, port or socket and protocol selected for the failed route and compare it with the actual intended listener. A neighboring working route may use a different destination. An online process state cannot answer that route-level question. I would check a permitted request directly to the HTTP backend when appropriate, while keeping the working frontend and unrelated routes available. If a backend uses FastCGI, I would use the protocol-appropriate checks that the deployment provides.

When is restorecon helpful for a website denial?

It can restore labels from the configured file-context rules when SELinux evidence points to a mismatch. It is useful after comparing the current context and intended default, including a persistent mapping for a custom directory if one is required. I would verify the exact denied path, normal filesystem permissions and authorization evidence first. Applying a label command to an arbitrary web root does not explain a proxy timeout or an unrelated access rule.

Choose the observation that changes the diagnosis

  1. A local port-inspection command lists 8080 as well as 80. A colleague says the two lines prove a conflict. What should you compare first?

    Answer and reasoning

    Compare the complete local address and exact port for each socket and the ownership of the failed binding. The two port numbers are distinct. A broad text filter for 80 can match both, so use a socket filter that means the actual port, then compare bind scope and the relevant process.

  2. A GET on the right hostname returns 404 only for a requested handout. The error shows an unexpected directory between the root and filename. Would opening a firewall rule solve it?

    Answer and reasoning

    The request already arrived and received a response. The failing path shows where the chosen mapping looked. Read the location and its root or alias, compare the intended filesystem path, and fix the specific placement or route. A network rule change would not change the server's calculated disk path.

  3. One proxy route returns 200 and the other points to a port with no listener. Does a 502 mean the backend returned an HTTP 502?

    Answer and reasoning

    In this case there was no accepted connection at the failed target, so the backend never returned an HTTP response for that request. The gateway produced 502 for the failure. The access log may show an upstream status value for that failed proxy attempt, and the matching error log explains the refusal. Together they prevent confusing the gateway result with an application response.

  4. A student updated a page and a HEAD check returns 200. What request would tell you whether its wording changed?

    Answer and reasoning

    Run a GET to the intended hostname and path and compare the response with the expected new marker. HEAD gives useful headers but no body. If the GET still shows the old content, compare the intended origin and expected normal route before deciding whether the file, mapping or a cache is involved.

  5. A diagnosis report says, “Local HTTP worked, so I disabled certificate verification to show that HTTPS works too.” What evidence is still needed?

    Answer and reasoning

    Use the correct public name, connect through the intended route and preserve normal certificate validation. Verify the TLS result and then the named HTTP response. Local HTTP only established a cleartext route. Bypassing certificate verification skips a part of what a student's ordinary HTTPS visit must succeed at.

Cards for a troubleshooting notebook

Make the vague report specific

Record the method, scheme, host, port, path, time and expected result. A distinctive marker can separate a working site from a successful fallback.

Bind errors name a local socket

Compare the actual addresses and ports. Identify ownership before changing a service. Separate loopback exercises can use independent ports and logs.

Follow the failing file

Use the request path and selected mapping to predict the server's filesystem path. Compare no-such-file and permission-denied evidence before altering access.

Find the selected upstream

Read the proxy's error with the exact route and target. Compare its listener and protocol against the intended backend. Keep working comparison paths as evidence.

Transport then TLS then the HTTP route

Only interpret an HTTP status after the earlier connection stages succeed. Keep local and normal external observations separate in the handoff.

Official references