Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)
7.3 Step 1 (common): create the sample website
Now open your terminal and try this with me. Run this on the server (it creates ~/mysite with an index.html, a CSS file and a custom 404 page):
आता टर्मिनल उघडा आणि माझ्यासोबत हे ट्राय करा. हे सर्व्हरवर चालवा (हे ~/mysite मध्ये index.html, एक CSS फाइल आणि custom 404 पेज बनवतं):
अब टर्मिनल खोलो और मेरे साथ ये ट्राय करो. इसे सर्वर पर चलाओ (ये ~/mysite में index.html, एक CSS फ़ाइल और custom 404 पेज बनाता है):
mkdir -p ~/mysite/css
cat > ~/mysite/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Cloud Website</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header><h1>Namaste from AWS EC2!</h1></header>
<main>
<p>This static website is served by a web server running on an EC2 instance.</p>
<ul>
<li>Cloud: Amazon Web Services</li>
<li>Server: EC2 in the Mumbai region</li>
<li>Content: HTML + CSS</li>
</ul>
</main>
<footer>Hosted as part of the AWS Hands-On Handbook lab</footer>
</body>
</html>
EOF
cat > ~/mysite/css/style.css <<'EOF'
body { font-family: Arial, sans-serif; margin: 0; background: #f4f7fb; color: #222; }
header { background: #0b3d6e; color: #fff; padding: 20px; text-align: center; }
main { max-width: 700px; margin: 30px auto; background: #fff; padding: 20px; border-radius: 8px; }
footer { text-align: center; color: #777; padding: 20px; }
EOF
cat > ~/mysite/404.html <<'EOF'
<!DOCTYPE html><html><body><h1>404 - Page not found</h1><a href="/">Go home</a></body></html>
EOF
ls -R ~/mysite
Ravindra Bagale's Tip
Many students write <<EOF (without quotes) instead of <<'EOF' in a heredoc – then the shell replaces words with $ and the file comes out wrong. Keep the quotes, and write the closing EOF at the start of the line with no spaces before or after.
Ravindra Bagale's Tip – मराठी
खूप students heredoc मध्ये <<'EOF' ऐवजी <<EOF (quotes शिवाय) लिहितात – मग shell $ वाले शब्द बदलून टाकतो आणि file चुकीची बनते. Quotes ठेवा, आणि शेवटचा EOF line च्या सुरुवातीला, आधी-नंतर space शिवाय लिहा.
Ravindra Bagale's Tip – हिंदी
बहुत students heredoc में <<'EOF' की जगह <<EOF (quotes के बिना) लिखते हैं – फिर shell $ वाले शब्द बदल देता है और file गलत बनती है. Quotes रखो, और आखिरी EOF line की शुरुआत में, आगे-पीछे बिना space के लिखो.
Lab
Chala, varchi commands chalvun ls -R ~/mysite bagha. Mag nano ~/mysite/index.html ughdun <h1> madhe "an Amul-style dairy – Daily Milk Rates" liha aani cat ~/mysite/index.html | head -12 ne badal zala ka te check kara.
Extended teaching notes
Why this lesson matters
Cloud security is mostly IAM, network exposure, logging and secure defaults. The shared responsibility model means the provider patches the metal; you patch what you configure.
- No public databases or public admin panels.
- Roles / OIDC instead of long-lived access keys.
- CloudTrail / Activity Logs / Audit Logs on and retained.
- S3/Blob/GCS: Block Public Access; encrypt; least privilege.
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)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- 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.