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

Chapter 10: Dynamic Website Hosting (PHP, Python, Node.js with MySQL)

AWS Cloud

Common Mistakes I See Students Make

Friends, I see these dynamic-site mistakes in every batch – passwords in code, the IPv6 mix-up with localhost, the app dying when SSH closes. Read them once.

  • Hard-coding passwords in source. Keep secrets outside source, public paths and deployment artifacts. Use the approved runtime credential mechanism and rotate any exposed real value.
  • Endpoint mismatch. A connection error for ::1 records an IPv6 attempt. Match the address or hostname to the assigned database listener.
  • Depending on a login session. A terminal run is useful for local testing. Set up the assigned managed lifecycle for a retained service and verify it under that identity.
  • Two independent starts for one listener. Give the app one launch owner. A systemd-managed PM2 daemon can be a valid ownership chain.
  • Exposing a backend listener unnecessarily. Keep database and app access within their approved sources and routes. Use the public front for intended client traffic.
  • Changing host-wide policy for a 502 without evidence. Check the upstream and look for a relevant SELinux denial. Use the assigned narrow policy procedure if needed.
  • Assuming web workers loaded a module. Check the actual PHP runtime and current worker settings before the approved reload or restart. Verify a real PHP route.

The same mistakes in other languages

Passwords in code: the safe version per stack

The first mistake on the list (hard-coded passwords) is the most dangerous. Each stack needs a runtime delivery method suited to its environment and credential lifetime.

PHP

The assigned PHP runtime should receive its approved credential explicitly. A protected local file, if used, belongs outside the public and packaged paths.

$pass = getenv('DB_PASSWORD');
Python / Flask

Use the dedicated service identity and a private projected credential on supported systemd systems. The Flask app example reads that projection.

LoadCredential=db-password:/etc/workshop/db-password
Node.js

Use the approved managed secret source. Avoid putting raw values in a process config or retained process dump.

./node_modules/.bin/pm2 show student-express-lab
Java / Spring Boot

${DB_PASSWORD} in application.properties.

spring.datasource.password=${DB_PASSWORD}
.NET

Environment variables override appsettings.json, using a double underscore for nesting.

ConnectionStrings__Default="Server=..."
Go

os.Getenv, and fail fast if it is empty.

pass := os.Getenv("DB_PASS")
Ruby / Rails

Encrypted credentials or ENV.

ENV.fetch("DB_PASS")

Why localhost vs 127.0.0.1 matters

A connection error for ::1 means the client attempted IPv6 loopback. When the assigned database really listens on IPv4 on the same host, an explicit 127.0.0.1 can match it. Use the assigned private DNS name or address for a remote service.

Real example

Global: automated bots search public GitHub repositories for database URLs and cloud keys. Many teams have found leaked credentials being used within hours. Everyday: you would not write your ATM PIN on the card.

What you see for each mistake

MistakeYou see
App started in SSH, then the terminal closed502 a few minutes later
PM2 and systemd both running the appEADDRINUSE :::3000
SELinux boolean off (CentOS)502, and Permission denied in the nginx error log
PHP module installed, no restartCall to undefined function mysqli_connect()
Port 3306 open to the worldLogin attempts from unknown IPs in the MySQL error log

Indian company example (sample): a startup's MySQL on EC2 had 3306 open "for the reporting tool". Within days the error log showed thousands of failed root logins. Closing the port and using an SSH tunnel or SSM port forwarding fixed it.

Beginner questions I get in class

Q. Is pm2 or systemd better?
Choose one launch path for each app listener. A systemd unit can deliberately supervise PM2 while PM2 launches the app.

Key terms

  • Three tiers: Web, app and data.
  • WSGI / ASGI: Python app interfaces used by Gunicorn and Uvicorn.
  • PM2: Node.js process manager.
  • systemd unit: A service definition with restart and boot rules.
  • Least-privilege DB user: An identity limited to the databases, tables and operations required by its assigned task.
  • 504: Gateway timeout while waiting for a required upstream response.

Mini case study

Suppose we are a junior cloud engineer at a Bengaluru e-commerce startup (sample data). The team runs a PHP admin, a Node.js storefront API and a Python report job on two EC2 instances. Using this chapter, you write a one-page runbook: which service listens where, how to test and reload each one, which logs to read, and which ports are public (only 80 and 443, plus 22 from the office IP). New team members can then fix most problems on their own.

Recap

  • Use the approved credential source and rotate any exposed real credential.
  • App and database ports stay private.
  • Use a process manager, not an SSH session.

Use a release rehearsal to spot mistakes before learners do

A college club asks you to take over its workshop website. The course home is a collection of files, while a report needs code to look up current registrations. The club runs the web front and app on an assigned machine and keeps its data in a limited practice database. The previous volunteer could serve the report from an open terminal, but there is no verification record for a managed release. Start by describing the service goal in one sentence: a learner using the club's named site can read the current synthetic registration titled Morning practice. That gives you something measurable to protect while changing the deployment.

Beginners often combine four unrelated problems under the instruction “get the host working.” First there is code, which must understand the route and data. Second there is the running process and the manager which owns it. Third there are network listeners, public site routing and private dependencies. Fourth there are values and identities supplied to the running app, including the approved SQL role. A change can be correct at one boundary and wrong at another. The practice below checks them separately, then repeats the report request through the selected host.

Use each common mistake as a paired expectation. A deployment task should tell you what success looks like before you run it. For a new process, record the actual executable and start mode. For a front routing change, name the selected virtual host and upstream. For a database connection change, verify a read with the new assigned role and a real report. For a rollback, keep the known prior configuration and compatible app reference. Those details make the site supportable by the next person, even if they did not install it.

A value moved out of code still needs a secure home

A learner puts a database password into the code to make a quick example start. The app works, so the folder is pushed to a shared repository or copied into a public web root. The password was part of the release artifact. Anyone else who receives that artifact might obtain it, regardless of whether the app itself prints it. Put a documented key name in source and use the service's approved method to supply its value at runtime. A local one-use practice secret and a production managed credential don't have the same lifetime, storage or access requirements.

A file such as .env can help separate local setup from source in a disposable workspace. It must stay outside the public document root, outside the build package and outside source control. Narrow file permissions and verify the process that needs to read it. A Git ignore rule excludes matching untracked files; it does not erase a secret from history or automatically stop tracking a file already added. If a real credential was exposed, follow the incident procedure and rotate or revoke that credential. Removing the line in a subsequent commit does not stop anyone who already obtained the old value from trying it.

Environment variables can work for restricted local practice. They can also be inherited by child processes, retained in process management state or copied to an environment dump. A systemd unit's direct environment is not a general secret store. The Flask and Express examples show how an approved LoadCredential source can be exposed to the supervised process as a private credential file. A deployment on AWS may use a service role permitted to retrieve just its assigned Secrets Manager secret, and use its deployment mechanism to pass the appropriate private configuration. Choose a method matched to identity, access, rotation and output rules. Verify where the value exists before telling the next learner that it is safely configured.

Think through rotation as a timeline. The deployment needs a planned way to get the new credential, establish a new connection and prove its narrow operation. A successful read through a pool of old sessions may not show that a fresh process can authenticate with the new value. Verify the new path under the planned transition and retire the old value at the right point. Busy operations, multiple instances and process-manager caching can make a changed configuration file different from the values currently in use. Keep the test evidence to a secret label, time and success of the intended operation. Never print the secret to demonstrate that it exists.

Do not give an application more database access than its job

The college club needs the app to list registrations. It does not need the app to create users or remove database tables. Give its runtime identity the query permissions needed on the intended tables. Use a separate scoped migration identity when schema changes are part of the approved deployment. If a disposable exercise needs to insert a synthetic row, give the practice writer only the added permission required, with a separate lifecycle. In MySQL, the host component helps determine which account is matched. The actual authenticated account and connection method matter as much as the username printed in a handout.

Suppose a SQL client running in an administrator's session can list the rows, while PHP reports a denied operation. There is no contradiction. The privileged test did not use the runtime account's grant or connection path. Compare the database name, readable initialization method, host or socket address and configured application user. With authorization, use the same transport and identity for a narrow read. Keep that probe to a known synthetic table or approved rows. Being able to reach a server shows connectivity. Successful authentication shows the server accepted a role. A successful check of the real statement is what shows the data layer can supply the report.

Be specific about scope. Least privilege describes the permissions required to perform an assigned job. For one app it may be SELECT on two report tables. For a form that accepts registrations, it may also include an INSERT on one table. For an application using a queue, multiple distinct roles can carry different responsibilities. Giving every app every permission within its own database still leaves excessive scope. Select permissions and network rules independently. Database authorization governs the operations a connected user can perform. Network policy constrains which clients can reach the listener at all.

Match addresses to listeners instead of copying a port rule

Look at three endpoints before creating any AWS rules. The reader contacts the website listener on its designated public address or load balancer. The web front connects to a service address that is reachable from that front. The app independently connects to a database endpoint it can reach. Only the components that are supposed to communicate should be able to do so. In a same-host demo the front and app share a network namespace, and a private IPv4 loopback connection is adequate. Across two hosts, the front and app need a private interface or another approved transport. The address must reflect that boundary.

Binding to 0.0.0.0 means all IPv4 local addresses for this listener. It does not guarantee that any particular client can reach the host. Routing and access rules still matter. Binding to 127.0.0.1 is a different choice. It limits requests to loopback connectivity within that networking environment. The next component's 127.0.0.1 must refer to the same environment for this to work. A container, other EC2 instance or load balancer has its own environment. Use an explicitly reachable private listener and relevant sources when designing a separated backend.

localhost is a name. It can resolve to IPv4 loopback, IPv6 loopback or both. If an error shows ::1, the attempted connection used IPv6. If MySQL listens only on IPv4 in the same host, a matching explicit IPv4 loopback address may be appropriate. If the database belongs to Amazon RDS, the correct address is the assigned database endpoint and the private network access path, not the app's own loopback. Compare logs and actual addresses before deciding that every connection should use an IPv4 literal. The error tells you which address was tried. It does not select the system design.

A public site listener can return a healthy response from the wrong configuration when several websites share a port. A raw IP check may select a default virtual host. A named HTTPS check proves more about the person's intended route, including the certificate. A loopback test for the backend is still useful because it removes the name and front mapping from that part of the investigation. Write down what each probe can establish. A single security group or TLS check cannot prove that the right club report appeared.

Use one launch owner and confirm the managed runtime

Running node app.cjs or python app.py in a terminal is useful for an isolated exercise. It makes startup messages and the chosen listener visible. A terminal attached process is usually coupled to a login session and has no managed boot or restart policy by that choice alone. The shell where you installed a project can also supply a different working directory, interpreter path, module tree and environment. Reproducing a foreground command from an SSH window is only the first part of verifying a durable managed deployment.

Pick a single process ownership chain. A direct systemd unit can start and watch an assigned app. PM2 can manage a Node process. PM2 might itself be managed by a systemd unit in a deliberate arrangement. In that case the unit owns PM2 and PM2 owns the app. That differs from both systems independently starting the same app listener. Make a simple record with one line naming which process starts the app and one naming who starts it at boot. Compare the configured network listener with the application release. Two valid managers can still conflict if they independently launch processes on the same socket.

Boot enablement and runtime restart are also separate. Enabling an installed unit for an appropriate boot target does not mean that the service started now. A configured restart policy manages certain exits after start. It does not fix a misspelled startup command or make an absent table appear. Test the expected startup and read under the assigned manager. A full reboot test belongs only to an authorized disposable host or a separately planned lifecycle check. A service-scoped restart during a safe rehearsal gives evidence for many changes without rebooting unrelated applications.

For PHP, the command-line interpreter can use a different configuration and modules from PHP-FPM or Apache. When a PHP page fails after a module installation, verify which executable or SAPI handled the web request and whether the live workers loaded the intended config. The answer can involve reloading or replacing only the assigned managed workers under their package rules, after config validation. Verify a harmless working PHP route, not only php -m in your login shell. If a front could expose PHP source by treating it as static text, use the assigned containment and configure the specific handler before accepting new traffic.

Verify the candidate report before changing the front path

Imagine release A uses a dataset with IDs and report titles. Release B's start command accidentally selects a reduced dataset containing only IDs. It can answer at its own listener, so a cheap health probe succeeds. Even readiness may pass when it checks only the ID column. Point the public front to B based on those probes and the report will fail on its first real query. The deployment error occurred at the release selection and user-result check. It cannot be prevented by restarting every instance or by adding more health URLs which observe the same inputs.

In a cautious rehearsal, start the candidate on its own assigned private port. Validate the expected route and response body directly before switching traffic. Plan a narrow rollback to the previous endpoint if the front-facing evidence is wrong. A production blue/green change may separate two full environments and shift traffic with a chosen AWS mechanism. This practice uses two local processes for the same idea. It intentionally makes no live deployment or cloud change. A local front config switching one path also does not imply that all database migrations can be safely undone.

Prepare two compatibility rows. Write version A's expected data schema and version B's. A user-facing change is safe to roll back only if the prior app works with the actual data still present. A schema change can remove a column the prior code needs, or represent new user writes the prior version cannot interpret. Consider a staged change where you add a field, deploy code that understands both formats, and retire older fields only after the old version no longer needs them. Use approved migrations with backups, explicit recovery planning and compatibility checks. The small rehearsal tests a routing choice, so both data files remain deliberately independent.

Do not confuse configuration syntax validation with correctness. A mismatched but existing upstream port can still appear in a syntactically valid config. A valid server block can still serve a wrong default page. A valid SQL statement can run on the wrong dataset. Review the route matrix and run both reader-facing and diagnosis probes. Verify content, type and status. If preserving unrelated sites is part of the assignment, test a known unaffected path for each in scope. A successful restart reinforces that startup works; it never supplies the content acceptance check on its own.

Lab one. Start two local candidates and compare their evidence

Prepare an empty local directory and reuse the two seed datasets and app source from the troubleshooting lesson. Keep the data files and Python app in the private exercise workspace. You need curl, Python with SQLite and, for the next stage, your approved Nginx executable. Check the practice ports on your machine before starting either process. These are example ports. If you choose replacements, update the app launch commands, curl probes and corresponding front config lines together. This workspace has no real student data or credentials.

# Terminal A: previous known-good release
python3 diagnose_app.py --dataset complete-lab.sqlite3 --port 18966

# Terminal B: candidate with only part of the required schema
python3 diagnose_app.py --dataset partial-lab.sqlite3 --port 18965

The app code is identical for both. Its selected data path gives the candidate a different release outcome. Start each in its own terminal so its outputs and cleanup are separate. In a third terminal ask both for health, readiness and the actual report. A lightweight check returns 200 from each. The candidate's real report cannot read its required title field. Match the failure to the operator event using the application's request identifier, and state which check should block a deployment.

for server_port in 18966 18965; do
  for route in /health /ready /api/registrations; do
    printf '%s %s\n' "$server_port" "$route"
    curl --noproxy '*' --max-time 5 --include "http://127.0.0.1:$server_port$route"
    printf '\n'
  done
done

The correct launch plan leaves the front pointing to release A because the pre-publish checks find B's problem. In the second stage, you intentionally compare the two live routes in an isolated Nginx copy to practice restoring a prior selection. Before starting the proxy stage, record what you already know so you can distinguish a front route effect from the application fault. Your direct request to candidate B reached that process, and its narrow checks passed. Both the report response and its linked event identify a query-phase failure.

Lab two. Detect a wrong default view and rehearse a rollback

Working in the same private directory, create logs and save the following as nginx.conf. Select a free assigned port for the front. The exercise only listens on loopback and never uses a real domain. The example name is under the reserved .test domain. The first server block simulates a perfectly functioning but unrelated default site. The second routes the named workshop site to the known-good data source. The front log records the selected server and configured upstream evidence. Use it with the app terminals.

worker_processes 1;
pid nginx.pid;
error_log logs/error.log info;
events { worker_connections 64; }

http {
    log_format release '$server_name "$request" front=$status upstream=$upstream_status target=$upstream_addr';
    access_log logs/access.log release;

    server {
        listen 127.0.0.1:18967 default_server;
        server_name unrelated.example.test;
        location / {
            default_type text/plain;
            return 200 "unrelated practice home\n";
        }
    }

    server {
        listen 127.0.0.1:18967;
        server_name club.example.test;
        location / {
            proxy_pass http://127.0.0.1:18966;
        }
    }
}
mkdir -p logs
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -t
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -g 'daemon off;'

Start the front in its own terminal. Use the exact executable and invocation for this private config. Validate the test output before starting it. In another terminal compare a raw address request with a named request. Curl --resolve supplies the private address for the exercise hostname and port. It keeps the hostname in the URL so the named server block can be selected. Its result is a private routing test. It says nothing about a DNS record or real internet host.

curl --noproxy '*' --max-time 5 --include http://127.0.0.1:18967/api/registrations
curl --noproxy '*' --max-time 5 --include \
  --resolve 'club.example.test:18967:127.0.0.1' \
  http://club.example.test:18967/api/registrations

Both can return 200 at the beginning. The first body says unrelated practice home and is plain text. The second returns the JSON workshop report, with the expected title and count. An availability script that reads only a status code and the IP address would approve the wrong site. The front access log should show the default name for one row, the named host for the other and an upstream target only for the proxied request. That evidence explains the difference even if a learner initially copied only the two status lines.

Now use a small acceptance check that fails if either transfer or result is wrong. Save it as check_report.sh in this private workspace, and run it with the shell. The code compares exact fictional content from the known dossier. In a real deployment, prefer parsing the structured response and verifying the required fields, identities and data with an approved test. This lab only needs a fixed synthetic marker. The expected type can be checked as part of a separate header probe.

#!/bin/sh
set -eu
report=$(curl --noproxy '*' --fail --silent --show-error --max-time 5 \
  --resolve 'club.example.test:18967:127.0.0.1' \
  http://club.example.test:18967/api/registrations)
printf '%s\n' "$report" | grep -F 'Morning practice' >/dev/null
printf 'Named practice site delivered the expected report marker.\n'

Make a copy of the working configuration as nginx.known-good.conf. Only for the practice scenario, change the target port in the named virtual host to 18965. Test the private config before reloading it using the private prefix and file. Use a separate operator terminal in that directory. The other Nginx master, if there is one, must be left alone. The specified PID file is inside the practice folder, so the signal is scoped to that running instance. After reload, probe until the selected target appears in the private log. The old worker may finish work already in progress during a graceful reload.

# Before editing the private configuration:
cp nginx.conf nginx.known-good.conf

# After changing only the target to the practice candidate:
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -t && \
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -s reload

Run the named report check again. It should fail with the app's 503 on the report while health and the default site's response remain ordinary. Read the target in the front log and match the candidate's operator event. The correct public hostname was chosen, but the candidate could not answer its actual data contract. A second syntax test can still succeed. Use the previous file and the private activation procedure to restore the target, then check that the named report returns the expected marker and the other host still shows its private default. This is a completed rollback test, rather than only proof that you copied a file.

cp nginx.known-good.conf nginx.conf
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -t && \
nginx -e stderr -p "$PWD/" -c "$PWD/nginx.conf" -s reload
sh check_report.sh

Trace the private sequence in order. Complete candidate A delivered both rows directly. Candidate B's shallow checks passed while its data failed. Both front configurations parsed. The named report failed only when it used B. Restoring A produced the previous report, and the unrelated default remained testable throughout. Stop the private Nginx and both app processes from their owned terminals and verify the assigned ports no longer listen. Remove only your disposable exercise files if finished with them, or retain the worksheet for the follow-up task. The lab illustrates a consistent route change and does not require restarting an AWS instance.

Use the acceptance checks as a small change review

Consider what would make this worksheet different for PHP. A normal app probe may need to go through the assigned front route because PHP-FPM expects FastCGI and does not give your curl an independent HTTP endpoint. Record the web server's actual handler, socket or address and expected application result. Static images can continue working while PHP requests are aimed at the wrong worker. Browser success for a neighboring asset is useful, but it is evidence about a different path. A controller HTTP route in Flask or Express may be directly testable on loopback, which helps separate front mapping from backend execution.

Do the same for canary testing. A canary gives a limited audience or portion of traffic the candidate first. Decide which successful result would be meaningful for that audience. If the next deploy changes only the error response template, a report marker and known denied route can be enough for a focused check. If the change introduces a new registration write, read-only success leaves out the new behavior. A dedicated authorized practice transaction with a stored synthetic result and defined cleanup becomes useful. Use an agreed observation interval and appropriate log or metrics scope before broadening traffic.

For supporting state, ask where a browser session, uploaded attachment and pending work item will live if another app process handles the next request. Local files and process memory are tied to their owners. An app running across several instances may need shared durable storage, an external authorized session scheme, or deliberate routing choices. Treat caches as temporary copies. A correct report can appear stale because a browser or proxy reused an earlier response. Choose freshness and access settings according to the data's use and confidentiality. Separate a cache explanation from a missing database write by comparing controlled reads on the actual request path.

Guard against overbroad quick fixes. Disabling a host security policy, making a credential readable to all users or opening a database listener to public clients can make a narrow symptom disappear while changing the entire service boundary. Such a result does not establish the original cause. Preserve the planned access controls and inspect the precise mistake. For permissions, identify which identity needs which file or downstream operation. For network reachability, identify the actual source, destination, port and listener. For application failures, check the route and data conditions, and keep the change within the responsible service.

Make the deployment reproducible under the operator's account

Another common report is, “I installed the package and it works on my terminal.” Start by asking exactly what command in which folder worked. Python's package installer can belong to a system interpreter while Gunicorn runs within a virtual environment. The Node command produced by an interactive version manager can differ from the absolute runtime in a service definition. PHP-FPM and the PHP command line can see different settings. A working test under your login can be useful during development. To teach hosting, capture the runtime, project revision, dependency set and identity the installed service uses.

Keep dependency intention and resolved versions separate. A project declares its required packages and supported versions. A checked and retained lock can record the concrete set used for a release. During rehearsal, rebuild the app from that reviewed set in a fresh owned environment. Ask which changes entered with the release and whether a software version, project code and database schema still agree. Do not update packages directly on a shared runtime while investigating an app's missing dependency. It could change other apps and remove the exact evidence needed to reproduce the failure. Scope your rebuild to the candidate you own.

Permissions are part of repeatability. The dedicated app account may need to read code and a credential at runtime. It rarely needs to own the web server's configuration or modify its own release source. A script serving uploads needs writes only in the chosen data location. If permissions keep the app from starting, determine whether it failed opening an executable, directory, credential or socket. Write the minimum needed access as a deliberate change and verify it under the service's real account. A new owner seeing permission denied should have an obvious next scoped observation, such as check the approved credential path and whether the runtime received it.

Keep one simple comparison sheet in the assignment. For the manual run, record the command, work directory, runtime version and expected route. In the managed column put the actual deployment file, dedicated identity and private configuration source. Highlight any intended difference, such as the write gate being disabled in the managed service. Add a fresh startup check. If a global package or hidden current working directory made the terminal run succeed, the managed check makes that reliance visible. Retain the approved release config and instructions for rebuilding a disposable copy. Document how to find logs without requiring credentials from the previous developer's personal login.

Different people need different kinds of deployment evidence

A club trainer needs to know whether learners can see the right timetable. An application developer needs the matching release and request evidence. A database owner needs the assigned role, schema and allowed operation. A platform operator needs the intended service listener and its owner. A common handover mistake is handing all four people an administrator's shell history. The history can be both overly revealing and insufficiently specific. Write an intentionally scoped note containing the expected operation, which evidence you checked and who owns the next layer if it fails.

Use concrete observations in the note. For the trainer, “The named workshop report returned two synthetic entries and displayed Morning practice” communicates the tested outcome. For the operator, “The front selected the club virtual host and logged target 18966” establishes the intended handling path. For the data owner, “The partial candidate connected and selected ID, but the report query required title” distinguishes a data contract gap from a data access failure. These statements describe the local example. In real operations, redact sensitive server and request details as required. Include the current release ID, timestamp, time zone and approved log location instead of copying entire logs to broad audiences.

Plan a separate follow-up when responsibilities cross a boundary. A developer can prove the code calls for a title field. The database owner can confirm which supported revision is deployed. The platform operator can confirm which configuration file the process loaded. Changing all three at once would make it harder to explain the original fault and harder to restore a working condition. Fix and verify the relevant boundary in a scoped order, then repeat the full report. The reviewer should be able to distinguish the exact completed change from ideas that were only considered.

Before closing the practice, mark the difference between a deliberately withheld promotion and a repaired application. You restored release A, so learners using the named fixture receive their report again. Candidate B still uses an incompatible dataset. A release note that calls B fixed because the front is now healthy would lead a second operator to promote it again. Record the missing candidate requirement and the test it needs before a future promotion. In a live change, separate restoration of service from completing the candidate work.

Practice correcting the advice you hear in an interview

Is a private dotenv file enough for every deployment?

For an isolated exercise it can separate a temporary value from source when access, packaging and lifetime are controlled. A real service needs the approved secret integration, runtime identity and rotation path for its context. A file already committed stays in Git history. If a real value was exposed, revoke or rotate it following the incident process and verify that the legitimate app can use the replacement through a fresh connection.

Should every backend always listen on loopback?

Use loopback when the authorized front and app share the relevant networking environment and communicate locally. A separate backend instance or container may require an explicitly reachable private address. Decide who may reach that listener, the required transport and how it is authenticated. Do not infer a public access requirement from an application listening port alone.

Why did enabling the Flask unit not fix the current app?

Boot enablement changes how the unit is attached to future target activation. Runtime status and startup correctness are separate. Inspect the actual start settings, run the approved assignment's service check and test the configured listener and report. A managed service cannot compensate for the wrong runtime executable or missing data credentials without those being corrected.

How does a public raw-IP health check miss the actual outage?

The request can select a different default site, as the two private server blocks illustrate. That unrelated site can answer 200 while the intended hostname's report fails. Run a named diagnostic and assert the content or data expected from the intended operation. Check TLS as normally configured for a hosted name. Use logs to confirm the right virtual host and target.

Why should you test compatibility before restoring yesterday's code?

The underlying data may have changed under today's release. Yesterday's application might not understand the new schema, format or writes. A code rollback has to restore an app and front route that work against the actual data. The local fixture avoids mutation and keeps both inputs, so restoring the old target is suitable for this specific rehearsal.

Decide which change fits the evidence

  1. A real SQL password was committed and then the file was ignored. Is the exposed value safe to keep?

    Show answer

    Follow the credential incident procedure and rotate or revoke the value. Ignoring a filename cannot remove an already committed secret from histories or other copies.

  2. A managed EC2 app must connect to an RDS instance in its VPC. Should its database address be the app's loopback?

    Show answer

    Use the assigned RDS endpoint and authorized private network path. Its database service is not a process listening on the app instance's loopback address.

  3. Can systemd be used with PM2 while preventing a port conflict?

    Show answer

    Yes when ownership is deliberately chained, for example systemd owns the PM2 daemon and only PM2 launches the app. Avoid independently launching two listeners for one socket.

  4. A changed Nginx config parses and the candidate health answers 200. Which lab check still blocks promotion?

    Show answer

    The candidate's full registration read fails on the partial schema. The health route and parser cannot prove that the actual report query works.

  5. The named report starts working after restoring the old target. What else should you verify?

    Show answer

    Check its expected synthetic row and nearby unaffected virtual host. Confirm the front log identifies the restored target and the service ownership matches the planned state.

Revision cards

Secret storage
Document the key name, use the authorized runtime delivery, and keep the secret out of client and source artifacts. Rotate any exposed credential.
Least privilege
Match the runtime account to the expected statements, tables and environment. Separate application use from migration administration.
Listener scope
Choose each bind and source for the actual path. The browser, web front, app and database can have different reachability requirements.
Single launch owner
One intended chain starts each listener. Check the managed interpreter, working directory, credentials and configured restart behavior.
Meaningful promotion check
Test the named route with the expected status, media type and content after a syntax test. Look for the intended downstream service evidence.
Verified rollback
Restore the narrow previous config and a compatible available app. Repeat the failing user operation, inspect logs and verify unrelated host behavior.

Score a proposed change before you accept it

Write a candidate release note for a workshop site with a public syllabus and a private registration list available only to authorized staff. Name the two first requests you will run and the body marker expected from each. Record the browser-to-front, front-to-app and app-to-data listener independently. Describe how the site verifies one denied inspection of the staff route with its normal authorization setup without altering real data. A working syllabus should not earn credit for the report. A web front record that says the proper hostname was selected helps confirm you did not read a default site.

Add a column for change review. Identify which files the deployment writes, the exact service that restarts and how its credential is delivered. Identify each effect that persists, such as a new lockfile, an added column or a boot setting. Describe the smallest rollback and show a compatible test after restoration. If the data migration cannot be rolled back safely, propose a recovery approach together with the authorized data owner. This exercise stays on paper unless the assigned environment is disposable and the data is synthetic.

Finally, exchange the note with another learner. They should be able to identify the expected site, supported framework route, storage query and intended service owner without reading the original setup script. Have them circle the first check that could pass while the report is wrong. In the local lab, a raw-IP status and a candidate health both pass in that situation. Improve your evidence until there is at least one check that can fail for the user outcome itself. Keep that check harmless and suitable for repeated use during the next approved release.

Official references

Quick revision cards

Revise this lesson in two minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens its lesson.

Comparison card: localhost vs 127.0.0.1. localhost: A name for 'this same computer'. 127.0.0.1: The IPv4 loopback address of this computer.
Comparison: localhost vs 127.0.0.1 · Download PNG

More cards: Ravi Sir's Cards.