This repo is a quick, practical walkthrough of how real deployments work using Flask, Waitress, and NGINX.
Each scenario builds on the previous one β starting from a basic dev server and moving all the way to HTTPS, virtual hosting, static file serving, and load balancing.
Perfect for understanding how modern web apps are actually deployed in the real world.
These scenarios have been given to us by our professor Dr. Priyank Thakkar
π Full Documentation:
π Detailed_Steps.docx
- π― Aim of the Practical
- π¦ Repository Structure
- π§ Concepts You Will Learn
- π Scenarios Overview
- βοΈ Setup & Usage Instructions
- π Scenario Descriptions
- π³ Commands Reference
- π SSL / HTTPS Notes
- β‘ Load Balancing Notes
This project helps you understand how real industry deployments work, including:
β How a web server operates β How to configure NGINX for different environments β How a dev server differs from a prod server β How to set up reverse proxies, virtual hosting, SSL, static file servers, and load balancing
By going through each scenario, you will gain the confidence to build robust production-grade deployments.
Deployment_Scenarios/
β
βββ Scenario_1/
βββ Scenario_2/
βββ Scenario_3/
βββ Scenario_4/
βββ Scenario_5/
βββ Scenario_6/
βββ Scenario_7/
βββ Scenario_8/
βββ Scenario_9/
βββ Scenario_10/
βββ Scenario_11/
β
βββ Detailed_Steps.docx <-- Full documentation
Each scenario folder contains:
- Flask app
- Nginx configuration
- HTML templates
- Additional config files if required
NOTE: This repo doesn't include Scenario-9 since it requires a domain setup.
- How Flask dev server works
- Why dev servers should never be deployed
- How Waitress serves production traffic
- Reverse Proxy
- Load Balancer
- Static asset server
- SSL / HTTPS termination proxy
- Virtual host manager (multiple domains on one or multiple apps)
- Host-to-IP mapping on Windows (
C:/Windows/System32/drivers/etc/hosts) - Handling multiple apps on different ports
- Running apps on different systems
- Sticky sessions & ip_hash
| Scenario | Description |
|---|---|
| 1 | Basic Flask Dev Server |
| 2 | Production Server using Waitress |
| 3 | NGINX Reverse Proxy to a Single App |
| 4 | NGINX + Waitress β Single App Handling Multiple Domains |
| 5 | NGINX with Multiple Server Blocks (two domains β one app) |
| 6 | Two Separate Apps on Same Machine (different ports) |
| 7 | Two Apps Running on Different Machines |
| 8 | HTTPS Setup with Self-Signed Certificate |
| 9 | HTTPS with Real CA (Letβs Encrypt / GoDaddy) (not implemented) |
| 10 | Serving Static Files Efficiently |
| 11 | Load Balancing + Sticky Sessions |
Open a terminal in your scenario folder and run:
python <app-file-name>.pyTo run multiple apps simultaneously β open multiple terminals.
Go to:
/nginx-1.26.3/
Start NGINX:
nginx.exeStop NGINX:
nginx -s stop # Force stop
nginx -s quit # Graceful stopReload configuration:
nginx -s reloadIf NGINX refuses to stop:
taskkill /F /IM nginx.exe /TEdit:
/nginx-1.26.3/conf/nginx.conf
Each scenario folder includes the required configuration blocks.
Below is a high-level summary of each scenario. Full configurations are present inside each folder.
- Runs using
app.run() - Debug mode enabled
- Auto reload
- Meant only for development
- Replace Flask dev server with Waitress
- Proper production WSGI server
- Accessible via system IP (
0.0.0.0)
- NGINX listens on port 80/1400
- Proxies requests to Waitress at
127.0.0.1:5001 - No domain names yet (local development)
- Domains:
my_site_1.com,my_site_2.com - One app decides response based on
request.host - NGINX server block handles both domains
- Proxy pass β
127.0.0.1:5005
- Each domain gets its own server block
- Same app receives both requests
- App identifies domain using
request.host
- App1 β port 5000
- App2 β port 5001
- NGINX routes based on domain name
-
NGINX routes traffic to different backend systems
-
Realistic distributed deployment
-
Example:
my_site_1.com β 10.53.163.247:5001my_site_2.com β 10.53.163.45:5000
-
Generate certs using OpenSSL
-
Use:
ssl_certificate ssl_certificate_key ssl_protocols ssl_ciphers HIGH -
NGINX listens using SSL on port 1400
You can use:
- Letβs Encrypt (Free)
- GoDaddy / ZeroSSL / DigiCert (Paid)
Use either:
location /static/ {
alias C:/path/to/static/;
}or
location /static/ {
root C:/path/to/project/;
}NGINX upstream block:
upstream my_waitress_servers {
ip_hash;
server 10.65.49.45:5000;
server 10.65.49.154:5000;
server 127.0.0.1:5000;
}taskkill /F /IM nginx.exe /Tipconfignginx -s reload- Private key
- CSR (Certificate Signing Request)
- Self-signed certificate
Used in Scenario 8.
For production, use CA-signed certs (Letβs Encrypt recommended).
NGINX supports:
- Round robin (default)
- Least Connections
- ip_hash (sticky sessions)
Used in Scenario 11 for session persistence.
By Shrey Vyas MLOps | Deployment | Cloud | NGINX | DevOps Learner