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

Chapter 6: Web Servers — Nginx and Apache

AWS Cloud

6.6 CentOS Stream 9

Friends, CentOS Stream 9 uses DNF. Check the web server’s actual package and service state, then inspect the firewall and SELinux layers only when their evidence matches the request.

Nginx on CentOS Stream 9

Inspect the selected package and service before an authorized change on an assigned host.

rpm -q nginx
systemctl is-active nginx.service
systemctl is-enabled nginx.service

Apache on CentOS Stream 9

rpm -q httpd
systemctl is-active httpd.service
systemctl is-enabled httpd.service

firewalld (only if it is running)

Check whether the assigned host runs firewalld. An authorized observation can identify the applicable zone and current policy.

firewall-cmd --state
firewall-cmd --get-active-zones

If the service is inactive or absent, confirm whether another host policy applies. In EC2, also inspect the relevant security group and intended listener. A local read-only test exercises its own route.

SELinux basics

Check the exact refusal before changing a policy. SELinux can affect file or network access. Use the mode, matching audit record and relevant web server error to determine whether it applies.

Check the host’s actual SELinux mode and policy. Static web content often uses a type such as httpd_sys_content_t. The permitted types and actions depend on policy, the actual process domain and the target object.

getenforce
ls -Zd -- /var/www/html
matchpathcon /var/www/html
# On an approved host where this exact sample file exists, preview label correction.
restorecon -n -v /var/www/html/index.html

Do not simply disable SELinux

Keep SELinux enforcing while you diagnose the lab. Reproduce the request and inspect recent AVC denials with sudo ausearch -m AVC,USER_AVC -ts recent. Check the relevant file label with ls -Z and compare it with the intended path policy. Fix the path context or the narrowly applicable setting, then retry the request. If there is no matching denial, also check ordinary file permissions, the web server log and the upstream service.

Ravindra Bagale's Tip

A move can keep an existing object’s label. Verify the resolved path, current label and expected context. Preview restoration for the exact approved file before applying any change and retest the request after correction.

Lab

Chala, record the assigned host’s observed SELinux and firewall state. Use the isolated loopback exercise below to reproduce an ordinary directory traversal denial and verify the same request after restoration.

Locate the denial before changing CentOS Stream settings

Mauli Dairy has a page that opens on one training server and returns 403 from another. The second system runs CentOS Stream 9. Someone suggests disabling the host firewall and someone else says to change every file's permissions. Both suggestions skip the most useful question: what operation did the system actually refuse? The browser reached an HTTP responder if it received 403. The responder might have denied an application route or hit a filesystem permission. The machine can also apply SELinux policy. Diagnose the request before choosing a change.

This lesson builds a small layered investigation. Confirm the release and the chosen package. Separate listener and network availability from the requested route. Then distinguish ordinary file access from mandatory access control. You will deliberately reproduce a 403 from a private Nginx instance under your own user, restore the exact directory search permission and see the response recover. The exercise does not require adding firewalld rules, changing SELinux modes or modifying the packaged web service.

The package examples reflect CentOS Stream 9 conventions. Local administrators can change how their images start services or configure policies. Use the actual tools and permissions of your assigned host. An EC2 security group, a host firewall, filesystem mode bits and SELinux each answer a different question. A learner does not need to alter every layer to understand how they interact. Use the evidence that matches the user-visible symptom.

Keep a diagnostic note with four fields. Write the exact request and observed stage, such as connection refused or HTTP 403. Identify the listener and the expected site. Name the operation that could not proceed and the evidence that identifies it. Then record the smallest appropriate retest. In our practice run the intentionally missing search bit explains the denial and restoring it changes the exact same request to success.

Choose the package and verify the actual startup state

CentOS Stream follows a continuously delivered distribution model in the Red Hat Enterprise Linux ecosystem. The example applies to Stream 9. Verify the exact local release, then use its DNF package tooling and enabled repositories. Nginx commonly comes from the nginx package with a matching unit. Apache HTTP Server commonly comes from httpd with httpd.service. Choose one for a given listener on an approved disposable host. A package name alone does not identify the process that currently owns a socket.

grep -E '^(PRETTY_NAME|ID|VERSION_ID)=' /etc/os-release
rpm -q nginx
rpm -q httpd
ss -ltn 'sport = :80'

Run each read-only line on the intended Linux host. The version output identifies CentOS Stream and release 9 on the target. An installed query can return a package build or report no installed record. The socket inspection can show an existing listener for TCP port 80. The address can distinguish a listener scoped to loopback, an explicit interface and a wildcard. A different site can use that port already. Verify its owner and purpose before planning any service operation.

On an assigned disposable machine where installation is approved, you can request sudo dnf install nginx or sudo dnf install httpd for the chosen server. Read the transaction proposal and confirm the package and repository. Startup and enablement depend on the local package and systemd policy. Check systemctl is-active and systemctl is-enabled for the selected unit. Use its authorized configuration test before starting or applying a change. Verify the current listener and exact response afterwards. A test site can use a separate port and configured root without changing the service used by an unrelated site.

The conventional Nginx configuration uses /etc/nginx/nginx.conf and can include files from /etc/nginx/conf.d. A packaged starter site commonly points under /usr/share/nginx/html. Apache commonly uses /etc/httpd/conf/httpd.conf, with a starter root under /var/www/html and included settings under its configuration directory. Read the actual site mapping before you assume an existing path is the one the request will use. This exercise chooses its own explicit document path, so we know precisely which directory permission we intend to test.

Read firewalld state in the appropriate zone

Firewalld is one host firewall management service available on CentOS Stream. Some images have it active, some use a different policy or are configured by their operator. Start with a current observation for the actual instance. If the caller is authorized to inspect the service, firewall-cmd --state can report it. On a systemd host, service state can be a separate clue. Then identify which active zone applies to the intended traffic. A zone is a grouping of rules that can be associated with an interface or source. A service rule listed in another zone may not apply to the client's traffic.

firewall-cmd --state
firewall-cmd --get-active-zones

Run these if installed and authorized. They are observation commands. The expected output for an active service can show its state and zones with active sources or interfaces. An error can indicate the service is absent, inactive or inaccessible to your account. Read the actual diagnostic. The default zone and the zone used by a connection need not be the same. Compare the intended interface and source to the operator's configuration. A classroom VM may have a public-labeled zone name even when all course traffic is private. The label does not by itself describe network reachability.

Within a known zone, the current runtime state governs its presently loaded rules. The permanent configuration describes what can be loaded by a restart or reload. A saved rule can differ from the runtime rule you are currently observing. Firewalld documents separate queries for these views. For example, firewall-cmd --zone=public --query-service=http asks about the http service in the runtime view of the zone named public. Use that name only if it applies in the assigned case. Adding the permanent option queries the corresponding saved configuration. The result concerns that exact service rule and zone. A separate port rule or policy could also affect the connection.

For this lesson, record the observed zone and result. Do not change rules to make a private loopback test work. If another assignment requires external access, establish the correct listener, approved client source and required destination port first. Confirm how administrative access and recovery are preserved. Opening HTTP and HTTPS by habit misses the point when only one path is intended. A cloud security group also has its own rule scope. A valid rule there does not make a missing listener start or a loopback-only process listen on a public interface.

Compare two hypothetical firewall observations

Start with a host that receives course traffic on its main network interface. The authorized operator's observation says the interface belongs to a zone called training. The saved configuration for a different zone called public includes the HTTP service. A student sees that saved rule and reports that the course request must be permitted. Follow the actual interface and source selection instead. The result concerns the rules used for the connection. The other zone's HTTP rule is an observation about another scope, even if its name sounds more appropriate for a public request.

Now suppose the training zone contains a permanent rule for an approved service but its runtime list has no equivalent. The saved configuration and current enforcement can have drifted after an operator's change. Compare both views for the same zone before planning a repair. A reload normally replaces runtime settings with the corresponding permanent configuration, so a runtime-only change can disappear. A reload can therefore affect more than the one rule a learner is investigating. Work through the owner of the firewall when the actual task needs such a change. The scope of our exercise is identifying the mismatch from two documented reads.

Review two examples of what a particular rule can say. A named HTTP service can represent a known set of port and protocol choices under its installed definition. A raw port rule can permit a different configured listener, such as an approved high-port training service. The presence of a named rule does not change either the listening address or the web server's configuration. If the listener runs only at 127.0.0.1, an outside connection cannot reach it through that address. If an approved site listens on the intended interface, you separately examine the upstream cloud policy and the local route. Keep the term service clear, since it can mean a firewall service definition or a program managed by systemd.

Practice reading a sample handover. “CentOS Stream 9 learning host. The assigned listener was verified on IPv4. The permitted caller comes through the training zone. The saved HTTP service rule is present in that zone, while the current view has no matching service rule. The local trusted test works.” This narrows a likely external difference. It still leaves other runtime rules, routing and client details open. A stronger next step is to compare the exact packet path with the approved runtime rules rather than opening both HTTP and HTTPS worldwide. If a proxy serves the public HTTPS endpoint and the instance is expected to accept only private HTTP from it, the right source and destination differ from an internet-wide rule.

Write a separate sentence for the cloud layer. The security group rules apply to resources associated with that group. The local host's rules are evaluated in its own networking context. Neither observation identifies the site that will respond after the connection gets through. A web response returned with a status indicates that at least one HTTP component answered. Identify whether that component is the instance worker, a load balancer or another service. This gives you a testable chain rather than a single statement that the firewall is on or off.

Understand the second file access decision

A normal Linux file check considers the process's active credentials and ordinary permissions. To open a file through a path, an ordinary process needs search permission on the directories and the relevant access on the file. An access control list can alter the ordinary discretionary result. SELinux adds mandatory access control based on labels, policy and the operation requested. A web worker that can reach a path under the ordinary mode bits can still be denied under enforcing policy. The normal permission bits do not encode the entire SELinux decision.

Start by checking whether SELinux is enforcing, permissive or disabled in the actual environment. Under enforcing mode, a denied action can be prevented even if ordinary access permits it. Under permissive mode, SELinux can log a would-be denial while allowing the action. The web service or another type of access control can still fail for a different reason. Package defaults and images can differ. If you want to connect a denial to SELinux, you need the actual policy state and a relevant observation, rather than the fact that the system is named CentOS.

getenforce
ls -Zd -- /var/www/html
matchpathcon /var/www/html

Run these read-only checks on an applicable training system with the tools and directory present. The listing can show the current context. The matchpathcon query asks for the default expected context for that path under local policy. They describe different facts. A standard content path can often have a type such as httpd_sys_content_t. That is one relevant content type. The effective policy can permit different types and actions. A process commonly uses a domain appropriate to its service package, but you should verify the actual domain for the selected worker. Avoid assuming a particular domain or file label applies to every build or path.

Consider a document moved within a filesystem. A move can keep the existing object and its label under a new name. A fresh copy can be created with permissions and context derived from the destination and the tool's options. The result can vary with how the move or copy is performed and which mounts are involved. Check the label after the operation rather than prescribing the same action for every move. For an approved path, the command restorecon -n -v followed by the exact file path can preview a context restoration without applying it. Use the correct local policy and scope before making an authorized change.

For a custom published tree on a managed system, its owner may need an appropriate persistent file context mapping and a planned apply. A folder for public read has a different job from a private upload folder that a service writes. A global boolean or a broad policy change can affect unrelated files or processes. Identify the specific label, path, domain and access requirement, then use the organization's documented procedure to apply a narrowly scoped correction. The lesson's ordinary file permission demonstration leaves the SELinux policy as it found it.

Read a denial record in the context of the request

A relevant SELinux audit message can say which process attempted which operation and what labeled target was involved. In an approved troubleshooting context, an administrator can query recent events for the relevant type. Associate them with a known request time and the selected operation. A log from another service or a previous request cannot explain the current one. On a system where the appropriate audit logs are already available, the following query is an observation. Review its output in that environment and share only the relevant record and safe file identifiers.

sudo ausearch -m AVC,USER_AVC -ts recent

The query's output can include a denied action such as read, search or network connect. It can also record labels for the subject process and target object. The subject is the process making the request. The target is the file, directory, socket or other object. Compare both to the expected access in the deployment. A denial for an attempted write is different evidence from a denial for reading a static file. If SELinux is permissive, a record may describe what would be refused. Check the actual request result and mode before concluding this policy blocked it.

A lack of matching audit lines leaves the diagnosis open. The expected logging service, time range, permissions and policy can affect what is visible. Check the web server's error log and ordinary access evidence. Confirm the exact path and worker identity. A file mapping may point to the wrong directory and a missing route can produce a similar symptom. For an upstream proxy error, verify the selected target, protocol and whether the intended backend listens. A 502 does not automatically point to a mandatory access control rule. Audit evidence for a network connect in the right request context gives a stronger basis for that inference.

Comparing these observations can tell you where to act. If the web log shows an attempted file open denied but policy is permissive, examine the ordinary parent and file modes and other applicable constraints. If it shows a verified matching denial under enforcing policy, inspect the expected label and access decision with the owner. If the client never connected to the intended listener, do not treat a filesystem label as a network fix. The symptom identifies the stage with evidence.

Match a sample audit record to a real operation

Use this fictional shortened record to practise reading the fields. A web worker tried to read a new pickup page after the deployment changed the document path. Its usual file permissions appear to allow that read. The environment reports that SELinux is enforcing. The request and audit times refer to the same observed attempt. Work through the fields before proposing a repair. The sample labels are illustrative and do not establish the right policy for another host.

avc: denied { read } for pid=4021 comm="httpd"
path="/srv/pickup/index.html"
scontext=system_u:system_r:httpd_t:s0
tcontext=system_u:object_r:user_home_t:s0 tclass=file

The action in braces identifies the denied operation. In this example it is a read. The command and PID help locate the process that attempted it. The subject context shows the worker domain in the example. The target context shows the file's current type. The target class says the object was a file. If you see another record for search on a parent directory, that is a separate attempted access. A useful report can say which action was refused at which path and compare it to the actual program and request. Quoting the complete audit log is often unnecessary and can expose other users' data.

Before asking to restore context, check what type the host expects for the actual published path. A generic application directory may have no site-specific mapping yet. Restoring its default cannot create a missing custom mapping. For an approved custom root, the administrator can choose a documented persistent mapping that covers the exact intended path and action. A temporary label alone may be reset by a restoration or relabel. The normal file ownership and permission requirements still apply. When you check the outcome, issue the same request and verify both the path and the response that the user needs.

A permission issue for a static read should not encourage the service to write every file. A web application that legitimately saves uploads can use a restricted writable directory with a different role from the read-only site root. Confuse the two and an unrelated worker may gain more access than it needs. An application's own request validation can also refuse an upload independently of the filesystem. Describe the actual operation you are testing before you make a policy change. A read-only pickup timetable needs a different access contract from a place where visitors submit files.

For a proxy decision, look for evidence of a network operation. A proxy can fail to connect if the upstream host or port is wrong, if the program is not listening or if policy blocks the connection. The matching audit event can distinguish a policy-denied connect from the other cases. Some SELinux policies supply booleans for classes of network access. A change can extend access for more than the single route that prompted it. Confirm the current policy and required scope with the owner before considering any change. This lesson keeps those controls in their current state and teaches you to identify when their evidence is relevant.

Now change one fact in the fictional record. Suppose the machine is permissive. The event can show a would-be denial without preventing the action. If the request still fails, inspect the ordinary path, active service identity and request route. If the request succeeds, the logged line can still help an administrator plan a future enforcement change. Whether the result occurred now and whether the policy would allow it under a different mode are two questions. Keep the exact mode in the note so a reader does not misdiagnose the system.

Set up a private server to observe an ordinary file denial

Use an assigned Linux learning host with Nginx already installed, Bash, Python 3 and curl. Use a normal unprivileged account. The exercise relies on the ordinary owner checks for its own files. If the system's approved policy prevents this temporary server from starting on a local high port, use the recorded example. Do not adjust labels, firewall configuration or security modes merely to run the lab. The command-line error-log option used here is available on Nginx versions supporting it. The setup checks that with the help command before creating any practice files.

unset cs_web_lab cs_web_port
if [ "$(id -u)" -ne 0 ] && command -v python3 > /dev/null && command -v curl > /dev/null &&
   nginx -e stderr -h > /dev/null 2>&1; then
  cs_web_lab=$(mktemp -d "$HOME/centos-web-lesson.XXXXXXXX") &&
    cd -- "$cs_web_lab" && mkdir ./site && chmod 700 ./site &&
    printf '%s\n' 'Pickup route reachable' > ./site/index.txt &&
    pwd
  cs_web_port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()')
fi

The setup prints the exact independent directory. Stop if the path was not created or an operation reported a failure. The root directory has an ordinary owner permission to traverse it. This is the only mode we will deliberately change. The file holds a fixed marker and keeps its own mode during the exercise. The chosen port is obtained from a temporary socket before the process starts. Another program could claim it in the meantime. If Nginx reports a bind error, inspect it and choose an independent port rather than stopping a different listener.

if [ -n "$cs_web_lab" ] && [ -n "$cs_web_port" ] &&
   [ "$(pwd -P)" = "$(cd -- "$cs_web_lab" && pwd -P)" ] && [ -f ./site/index.txt ]; then
  cat > ./nginx.conf <<EOF
worker_processes 1;
pid "$cs_web_lab/nginx.pid";
error_log "$cs_web_lab/error.log" notice;
events { worker_connections 32; }
http {
    access_log "$cs_web_lab/access.log";
    client_body_temp_path "$cs_web_lab/body";
    proxy_temp_path "$cs_web_lab/proxy";
    fastcgi_temp_path "$cs_web_lab/fastcgi";
    uwsgi_temp_path "$cs_web_lab/uwsgi";
    scgi_temp_path "$cs_web_lab/scgi";
    default_type text/plain;
    server {
        listen 127.0.0.1:$cs_web_port;
        server_name localhost;
        root "$cs_web_lab/site";
        index index.txt;
    }
}
EOF
  cs_nginx=(nginx -p "$cs_web_lab/" -c "$cs_web_lab/nginx.conf" -e "$cs_web_lab/bootstrap.log")
  if [ ! -s ./nginx.pid ] && "${cs_nginx[@]}" -t && "${cs_nginx[@]}"; then
    for cs_check in 1 2 3 4 5 6 7 8 9 10; do
      [ -s ./nginx.pid ] && break
      sleep 0.1
    done
    if [ -s ./nginx.pid ]; then
      cs_web_url="http://127.0.0.1:$cs_web_port/"
      curl --noproxy 127.0.0.1 -fsS --max-time 5 "$cs_web_url"
    fi
  fi
fi

The configuration uses one listener and one private static root. Both its process and temporary paths live in the directory you own. Nginx's syntax test can create an empty PID file, which the startup guard distinguishes from a nonempty one. Verify the intended process began and the response is the known marker. The process runs with your ordinary account in this isolated example. A packaged managed service on CentOS Stream can run other workers in another SELinux domain or through a different context. This test demonstrates the ordinary permission layer, independent of your host's packaged policy.

Reproduce the 403 and restore the exact bit

Keep the URL, process and file fixed. Remove just the owner's search bit from the private site's document directory and send the same request. Use a subshell so its cleanup trap will restore the expected owner search bit when the block finishes. The outside shell stays in your lab. A successful transfer returning an HTTP error is still an observation, so this request prints the HTTP status and discards the illustrative error body. The final request after the subshell should serve the same marker again.

if [ -n "$cs_web_lab" ] && [ "$(pwd -P)" = "$(cd -- "$cs_web_lab" && pwd -P)" ] &&
   [ -s ./nginx.pid ] && [ -n "$cs_web_url" ]; then
  ls -ld -- ./site ./site/index.txt
  (
    trap 'chmod u+x ./site' EXIT
    chmod u-x ./site &&
      curl --noproxy 127.0.0.1 -sS -o /dev/null --max-time 5 -w 'Access test HTTP %{http_code}\n' "$cs_web_url"
  )
  ls -ld -- ./site ./site/index.txt
  curl --noproxy 127.0.0.1 -fsS --max-time 5 "$cs_web_url"
  tail -n 4 ./access.log
  tail -n 4 ./error.log
fi

On the intended setup the temporary request should show 403 and the restored request should show the original marker. The error log can show a permission-denied path below the document directory. Read the actual operation. It may be a failed file status or open, depending on the particular version and mapping. You know this error followed the loss of directory search because you changed only that bit. The restored mode and response are the strongest immediate evidence. You did not need to change an SELinux label, firewall rule or application configuration. If you do not see the expected failure, restore the private mode and examine what account and site answered your test.

After verifying the report, stop the isolated master using the same process-specific command settings. Wait for the lab PID to disappear. Then identify the exact remaining files. The cleanup below assumes the instance started normally and created its configured log and temporary directories. If you stopped early, inspect which paths exist and remove only the sample files you own. Do not apply a broad deletion to the parent directory.

if [ -n "$cs_web_lab" ] && [ "$(pwd -P)" = "$(cd -- "$cs_web_lab" && pwd -P)" ] &&
   [ -s ./nginx.pid ]; then
  "${cs_nginx[@]}" -s quit
fi
ls -la -- . ./site
if [ -n "$cs_web_lab" ] && [ "$(pwd -P)" = "$(cd -- "$cs_web_lab" && pwd -P)" ] &&
   [ ! -e ./nginx.pid ]; then
  rm -i -- ./nginx.conf ./bootstrap.log ./error.log ./access.log ./site/index.txt &&
    rmdir -- ./site ./body ./proxy ./fastcgi ./uwsgi ./scgi &&
    cd -- "$HOME" && rmdir -- "$cs_web_lab"
fi

Keep any written observations outside the directory if you want them later. The removal asks for the expected files by name and refuses to remove a directory while it has unexpected contents. A validation-only attempt may leave an empty PID artifact. Check the actual state before deciding on its cleanup. A matching nonempty PID calls for an owned process shutdown. An empty fixture file does not identify a running master. Keep these states separate in your final evidence.

Read the controlled permission result precisely

Our demonstration started from an owner-only document directory. With mode 700, its owner can list and search the directory and can change its entries. The file inside can be readable while the directory supplies the needed name lookup. Removing owner search changes the owner set from read, write and search to read and write. That corresponds to 600 on this practice directory. The same numeric mode on a file means read and write for the owner. On a directory it leaves the owner without the search bit. Remember the object type when interpreting these numbers.

Nginx's worker tries to handle the same request through the same root. When the document directory loses its search bit, the worker cannot resolve the ordinary target path as before. The log identifies a permission denial for the intended file path. The access log for the same request reports 403. Your local client still reached and received a response from the listener. Therefore the result does not require any change at the cloud firewall. The process can continue serving while a particular route is denied. You can verify that the response content returns after restoring the bit.

The three observed results make a useful experiment. The first and last use the same config, listener, URL and file data. The middle test changed the directory bit. The file's own recorded modes can be compared separately. A teammate can identify the cause from that before-and-after record. Compare it to a case where you change several things at once. If you restart the process, change the root and alter the firewall in the same step, a recovered response alone leaves several possible causes. The controlled exercise deliberately keeps those choices fixed.

There are cases where a real service might not behave like the training worker. It could use another account, load an already opened file, serve a cached response, choose another root or be subject to additional restrictions. The practice server avoids those complications and uses a fresh request to a known static mapping. If the expected 403 never appears, verify the actual process and route before guessing why. Run the exact restoration even if the evidence is inconclusive. Collect enough information for a different learner to see which premise may have differed.

For a complete support note, identify the file and its immediate parent, the process or request path and the observed status. Include the relevant error text after removing any private paths that are unnecessary to the recipient. State what changed before the request recovered. If a real system needs an SELinux or firewall adjustment, include the analogous checks for target path or zone and an appropriate retest. A precise result is enough to train the next person to isolate the right layer.

When comparing more than one worker, read the context of the process that made the request. A service's parent can have different credentials from an individual worker. On an applicable Linux system, the process listing can include a security label field for an identified process. Use the approved unit and error evidence to identify the relevant worker before using it. A default account name alone cannot prove the process domain. An application using a separate backend can have different execution contexts on each side of the connection. If two services run under different labels, compare their paths and operations individually.

It is also useful to distinguish an expected mapping from the actual context of the resolved target. A symlink can lead to another directory or mount. Check which path the request actually opened and examine that object, along with the directories it needed to traverse. A copied config can give a correct apparent document root and still contain a route-specific override. In the controlled lab the mapping is deliberately simple so the denial can be attributed to one known bit. In a managed site the extra mapping evidence helps avoid adjusting permissions on the wrong object.

For a comparison across images, record the operating system release, package, active listener and security policy mode separately. An image that allows a request can still log a denial under permissive mode. Another image can enforce the same denial. In either case the first job is to describe the actual behavior and match it with the right evidence. Avoid drawing a distribution-wide conclusion from the result of one host.

Select the next check in three realistic cases

The following worksheet turns the previous material into decisions. Read the observations in each row. State which stage already worked, which stage may have failed and which single check you would collect next. Treat the examples as fictional. You can complete the exercise without administrative access and without running requests against systems outside your lab.

Observed resultStrongest current evidenceOne next check
Connection timeout from an approved outside client while the correct site works on the hostLocal listener and request answer successfully.Compare external address, listener binding and authorized rules along the actual path.
403 and matching file search denial under the worker identityHTTP reached the responder and the path operation failed.Compare the parent path and actual mode, ACL or context for that identity.
502 from a front end with a matching upstream connect errorThe front end accepted the request.Check the configured upstream address, protocol and applicable access evidence.

A good answer explains why each follow-up matches the observed failure. In the first case a web root read happened from the local context, which leaves the external connection in question. In the second, an actual HTTP response arrived, so start with the request's reported access failure. In the third, health of the front-end process leaves the upstream operation open. Choosing the next observation saves time and reduces the risk of making a change unrelated to the report. Use the exact request and timestamp whenever you compare logs.

For your last exercise, write an incident summary for the controlled 403. State that the initial loopback request returned the expected body. The same request returned 403 when owner directory search was removed. The matched error identified the file path and permission problem. The final test succeeded after only that bit was restored. Add the shutdown and cleanup result after verifying it. If you used the sample rather than running the lab, label it as an interpretation. These two versions of the report show which learning evidence you personally gathered.

Interview questions with worked answers

Does a 403 on CentOS Stream prove SELinux caused it?

It proves an HTTP responder gave a refusal. I check the route, identity and error log. If the relevant policy is enforcing and a matching audit denial exists, that is evidence for SELinux. The lab deliberately produces a 403 from ordinary directory search without editing the mandatory policy.

Why can a worker read a file on one host and fail on another with the same mode?

The active identity, directories, ACLs, labels and policy can differ. The site can also point to another path. I verify both actual request mappings and look at the relevant denial before choosing a change.

What is the difference between firewalld runtime and permanent state?

Runtime describes the loaded firewall state. Permanent describes saved settings which can be applied by reload or another activation. I check the relevant zone and both views when the task needs them. A saved rule can differ from the currently effective one.

What does a successful loopback request prove about an EC2 security group?

It proves local access to the intended listener under that request context. The public connection uses a different path that can involve security groups, host rules and address binding. I verify the authorized outside route separately.

What would you do if the target file's label differs from its expected context?

Verify the path and actual policy expectation, then preview a targeted checked restoration where appropriate. A custom document root may need an approved persistent context rule. Confirm the result under the intended identity and retest the same request.

Check your understanding

1. The browser receives 403. Which evidence should you read before changing policy?

A. The actual request's error, route and relevant access decision
B. The brand of the computer
C. Every available module name

Answer and reasoning

A. The response is an observed refusal. Several layers can produce it, so isolate the real request and exact operation.

2. Which observation distinguishes a runtime zone rule from a saved rule?

A. The site's page title
B. Separate queries for the same zone's runtime and permanent state
C. Running the package query twice

Answer and reasoning

B. The two views can differ. Also confirm that the selected zone applies to the destination traffic.

3. What is the controlled cause of the lab's 403?

A. A missing DNS answer
B. An edited cloud firewall
C. The practice web worker cannot search its document directory.

Answer and reasoning

C. We removed the owner search bit while keeping the process, URL and file fixed. Restoring that bit restores the read in the fixture.

4. What does a matching SELinux denial logged in permissive mode establish?

A. The policy would deny it under enforcing conditions.
B. The firewall certainly dropped the connection.
C. The log by itself proves the request failed.

Answer and reasoning

A. Permissive policy can log without enforcing the denial. Check the real response and other access layers.

5. Which path verify step helps after moving a file into a published directory?

A. Guess the label from the filename length.
B. Compare its current and expected context under the effective policy.
C. Replace every mode bit on the host.

Answer and reasoning

B. The actual context depends on the movement and policy. Inspect the intended file before deciding on a targeted repair.

Revision cards

Know the release and listener

Verify CentOS Stream 9, the installed package and the active socket before changing an assigned service.

Check the correct zone

Match the interface or source to the applicable firewalld zone. Compare runtime and permanent views where needed.

Separate file checks

Ordinary credentials, parent search and file mode matter. SELinux can add a label and operation-based decision.

Read a denial in context

Match its time, process, operation and target. Confirm the actual enforcement state before explaining the failure.

Retest the exact request

Use the same listener and content marker after a scoped change. Verify which evidence changed.

Keep the preview private

Its own loopback port, paths and PID make the experiment independent of a managed site. Clear only the owned fixture.

Official references