Web server basics: publishing a site
You publish a static site first with Python’s built-in server and then with Nginx, setting up paths, redirects, logs and HTTPS.
Level 201 · 18 lessons · 15 practice labs
Lessons
The first server
- What a web server does
- Quick publishing with python3 -m http.server
- Installing, starting and stopping Nginx
- Document root, index files and directory listing
- MIME types: how the browser recognises a file
- Short task: publish a three-page site
Configuration
- Server blocks and several sites
- Location matching and try_files
- Redirects: pointing old URLs at new ones
- Custom error pages
- Compression and cache headers
- Short task: set up redirects for moved pages
Logs and HTTPS
- Reading access and error logs
- Finding the most requested pages in a log
- HTTPS with your own certificate: a local CA and openssl
- Redirecting HTTP to HTTPS and HSTS
- Reverse proxy: putting an app behind Nginx
- Capstone: launch a company site over HTTPS
Practice labs
- Publish a folder at once: Serve the project folder on port 8080 with python3 -m http.server and verify from another terminal with curl.
- Serve a three-page site with Nginx: Install Nginx, change the document root and prove directory listing is off in a folder without an index file.
- Fix files that download instead of display: SVG and .webmanifest files won't open in the browser; fix the MIME type mapping and verify with headers.
- Add a second site: Add a separate server block for Çınar Café on the same server and show with curl that the sites are split by name.
- Serve a single-page app with try_files: Write a try_files rule for an app that returns 404 on deep links, checking static files are still served directly.
- Solve location precedence: Four location blocks overlap; predict which block five sample URLs hit, test it and fix the wrong match.
- Redirect a moved page: Point the old /hakkimizda.html address at the new /hakkimizda with a permanent redirect.
- Add a custom error page: Configure branded 404 and 50x pages for Ada Furniture and check the status codes are still correct.
- Apply a bulk redirect list: After a redesign, set up redirects for 20 old URLs with a map and test them all with a script.
- Count errors in the access log: Count the requests that returned 404 and 500 in the log and find the URL with the most errors.
- Find the most requested pages: From a week of access logs, find the ten most visited pages and the busiest hour.
- Find the cause of an outage in the error log: The site returned 502 this morning; match error and access logs by time and explain the back-end failure step by step.
- Redirect HTTP to HTTPS: Enable HTTPS with a local CA certificate and permanently redirect every request on port 80 to 443.
- Put an app behind Nginx: Publish the Node app on port 3000 through a reverse proxy and verify the real client IP reaches the app.
- Launch a company site over HTTPS: Launch Mercan Shipping's site from scratch with its own certificate, HSTS, compression and cache headers.
About this course
You publish a static site first with Python’s built-in server and then with Nginx, setting up paths, redirects, logs and HTTPS.
What you will learn
- The first server
- Configuration
- Logs and HTTPS
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.