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

16. Live Project: Building a Reels App with EC2, S3 and RDS

16.12 Testing and Troubleshooting

Symptom Likely cause Check / fix
502 Bad Gateway PHP-FPM stopped or wrong socket sudo service php-​fpm status; ls /run/php-fpm/ (Ubuntu /run/php/)
Blank page / 500 PHP error sudo tail -​f /​var/​log/​php-​fpm/​www-​error.​log (Ubuntu: /​var/​log/​nginx/​error.​log)
413 Request Entity Too Large Nginx body limit client_​max_​body_​size 60M; then nginx -t and reload
"Upload failed (error code 1)" PHP upload_​max_​filesize too small Check 99-reels.ini, restart PHP-FPM
"Could not store the video" IAM role missing/wrong, wrong bucket or region Log shows AWS error code; aws sts get-​caller-​identity; policy resource videos/*
SQLSTATE[HY000] [2002] Can't reach RDS nc -​zv <endpoint> 3306; db-sg source = web-sg
SQLSTATE[HY000] [1045] Wrong DB user/password Test with mysql -​h ... -​u reels_​app -​p
Videos don't play, 403 in Network tab Presigned URL expired or signed for wrong region Reload page; aws_region must match the bucket
Videos blocked, CSP error in console media-src doesn't match the bucket host Put your exact bucket host in the CSP header
Login loops back to login page Secure cookie over HTTP, or session dir not writable Use HTTPS; ls -​ld /​var/​lib/​php/​session
sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log
sudo tail -f /var/log/php-fpm/www-error.log               # Amazon Linux 2023
curl -s -o /dev/null -w "%{http_code}\n" https://reels.yourdomain.com/feed.php   # 401 when logged out

Ravindra Bagale's Tip

When an error appears, students start changing the code. Read the log first! Most of the time the answer is right there in error.log. Remember the order: browser DevTools (Network/Console) → Nginx error log → PHP-FPM log → AWS/RDS connectivity. Use this order and you'll find any problem quickly.

Practice task

Break the app on purpose three ways – stop PHP-FPM, detach the IAM role, remove the 3306 rule – and note the exact error and log line for each. Then fix them. This is exactly how you will think during incident response.

Extended teaching notes

Why this lesson matters

Cameras, sensors and plant controllers often ship with weak defaults. Segment them from IT, change passwords, block inbound internet, and watch outbound traffic.

Real examples

Global: Mirai showed what default passwords on routers/cameras can do at scale. Indian SME (sample): a factory puts PLCs on a separate VLAN reachable only via a jump host.

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.