Skip to content

sajjadghf/lectures-nginx-haproxy

Repository files navigation

📚 NGINX & HAPROXY WORKSHOP — ZERO TO HERO (FOR DEVOPS ENGINEERS)

Complete course materials organized by module


📖 Course Structure

Module 1 — Fundamentals module-01-fundamentals.md

Section 1: Introduction to Load Balancing & Reverse Proxies

  • What Is a Reverse Proxy?
  • Load Balancing Fundamentals
  • Why DevOps Engineers Need Nginx & HAProxy Knowledge
  • Common Use Cases
  • Layer 4 vs Layer 7 Load Balancing
  • Forward Proxy vs Reverse Proxy

Section 2: Nginx Basics

  • Nginx Architecture Overview
  • Master & Worker Process Model
  • Event-Driven Architecture
  • Nginx vs Apache
  • Installation Methods
  • Basic Configuration Structure

Section 3: HAProxy Basics

  • HAProxy Architecture Overview
  • HAProxy vs Nginx
  • When to Use HAProxy
  • Installation Methods
  • Basic Configuration Structure

Module 2 — Nginx Deep Dive module-02-nginx-deep-dive.md

Section 4: Nginx Configuration Essentials

  • Configuration File Structure (nginx.conf)
  • Context Hierarchy (main, events, http, server, location)
  • Core Directives & Parameters
  • Configuration Testing & Validation
  • Hot Reload & Graceful Restart
  • Include Files & Configuration Organization

Section 5: Worker Process Tuning

  • Worker Processes vs Worker Connections
  • CPU Affinity & Multi-Core Optimization
  • Event Models (epoll, kqueue, select)
  • Connection Processing Optimization
  • Memory Management
  • Lab: Optimize Worker Configuration

Section 6: HTTP Server Configuration

  • Virtual Hosts (Server Blocks)
  • Server Names & Name Resolution
  • Listen Directives & Port Binding
  • Root & Alias Directives
  • Index Files & Autoindex
  • Default Servers & Catch-All

Module 3 — Advanced Nginx Features module-03-nginx-advanced.md

Section 7: Location Blocks & Request Routing

  • Location Block Matching Rules
  • Regex Locations & Named Captures
  • Location Priority & Processing Order
  • Try Files Directive
  • Rewrite Rules & Redirects
  • Internal Redirects

Section 8: Load Balancing with Nginx

  • Upstream Configuration
  • Load Balancing Algorithms (Round Robin, Least Conn, IP Hash, etc.)
  • Health Checks (Active & Passive)
  • Upstream Keepalive
  • Backup & Down Servers
  • Sticky Sessions
  • Lab: Multi-Backend Load Balancer

Section 9: Proxying & Headers

  • proxy_pass Configuration
  • Proxy Headers Management
  • X-Real-IP & X-Forwarded Headers
  • Host Header Handling
  • Proxy Buffering & Timeouts
  • WebSocket Proxying

Module 4 — HAProxy Deep Dive module-04-haproxy-deep-dive.md

Section 10: HAProxy Configuration Essentials

  • Configuration File Structure (haproxy.cfg)
  • Global, Defaults, Frontend, Backend Sections
  • Bind & Server Directives
  • Configuration Validation
  • Logging Configuration
  • Stats & Monitoring Interface

Section 11: Load Balancing Algorithms

  • Round Robin & Weighted Round Robin
  • Least Connections
  • Source IP Hashing
  • URI Hashing
  • Random & RDP Cookie
  • Custom Load Balancing Logic
  • Lab: Compare Load Balancing Algorithms

Section 12: Health Checks & Monitoring

  • Layer 3/4 Health Checks
  • Layer 7 HTTP Health Checks
  • Custom Health Check Scripts
  • Check Intervals & Timeouts
  • Rise & Fall Parameters
  • Observability & Stats Socket

Module 5 — Performance & Optimization module-05-performance-optimization.md

Section 13: Nginx Performance Tuning

  • Worker Process Optimization
  • Connection & Request Limits
  • Buffer Size Tuning
  • Sendfile & TCP Optimizations
  • Gzip & Compression
  • Open File Cache
  • Client Body & Header Timeouts
  • Lab: Benchmark & Optimize Nginx

Section 14: HAProxy Performance Tuning

  • Maxconn & Connection Limits
  • Timeout Configuration
  • Buffer Tuning
  • Thread Model Configuration
  • Connection Pooling
  • Backend Connection Reuse
  • Lab: HAProxy Performance Testing

Section 15: Caching Strategies

  • Nginx Caching (proxy_cache)
  • Cache Keys & Zones
  • Cache Bypass & Purging
  • Cache Locking
  • Microcaching Patterns
  • Cache Warming Strategies

Module 6 — SSL/TLS & Security module-06-ssl-security.md

Section 16: SSL/TLS Configuration

  • Certificate Management
  • SSL Protocols & Cipher Suites
  • Perfect Forward Secrecy
  • OCSP Stapling
  • SSL Session Caching
  • HTTP/2 & HTTP/3 Configuration
  • Let's Encrypt Integration

Section 17: Security Hardening

  • Rate Limiting & DDoS Protection
  • Request Filtering & Validation
  • Security Headers (HSTS, CSP, etc.)
  • Access Control (IP Whitelisting/Blacklisting)
  • ModSecurity & WAF Integration
  • Bot Protection
  • Lab: Implement Security Best Practices

Section 18: Authentication & Authorization

  • Basic Authentication
  • JWT Validation
  • OAuth2 Integration
  • Client Certificate Authentication
  • API Gateway Patterns
  • Request/Response Modification

Module 7 — High Availability & Scaling module-07-high-availability.md

Section 19: High Availability Patterns

  • Active-Active vs Active-Passive
  • Keepalived & VRRP
  • HAProxy Peer Synchronization
  • DNS-Based Load Balancing
  • Geographic Distribution
  • Failover Strategies

Section 20: Container & Kubernetes Deployment

  • Dockerizing Nginx & HAProxy
  • Nginx Ingress Controller
  • HAProxy Ingress Controller
  • Service Mesh Integration
  • ConfigMap & Secret Management
  • Lab: Deploy HA Load Balancer on K8s

Section 21: Scaling Strategies

  • Horizontal vs Vertical Scaling
  • Connection Pooling
  • Backend Scaling Patterns
  • Auto-Scaling Integration
  • Multi-Region Architecture

Module 8 — Observability & Troubleshooting module-08-observability-troubleshooting.md

Section 22: Logging & Monitoring

  • Access & Error Logs
  • Custom Log Formats
  • Structured Logging (JSON)
  • Log Rotation & Management
  • Prometheus Exporter Integration
  • Metrics Collection
  • Real-Time Monitoring

Section 23: Debugging & Troubleshooting

  • Debug Logging
  • Connection Tracing
  • Common Issues & Solutions
  • Performance Bottleneck Analysis
  • Packet Capture & Analysis
  • Lab: Debug Production Issues

Section 24: Observability Stack Integration

  • ELK Stack Integration
  • Grafana & Prometheus
  • Datadog & New Relic
  • Distributed Tracing
  • APM Integration

Module 9 — Advanced Patterns & Use Cases module-09-advanced-patterns.md

Section 25: API Gateway Patterns

  • Request/Response Transformation
  • Request Aggregation
  • Circuit Breaker Pattern
  • Rate Limiting & Throttling
  • API Versioning
  • GraphQL Proxying

Section 26: Microservices Architecture

  • Service Discovery Integration
  • Blue-Green Deployments
  • Canary Releases
  • Traffic Splitting & A/B Testing
  • Service Mesh Comparison
  • Lab: Implement Canary Deployment

Section 27: Edge Computing & CDN

  • Edge Caching Strategies
  • Multi-Tier Caching
  • Edge Side Includes (ESI)
  • Purge & Invalidation
  • Geographic Routing
  • CDN Integration

Module 10 — Production Best Practices module-10-production-best-practices.md

Section 28: Configuration Management

  • Infrastructure as Code
  • Configuration Templating
  • Ansible/Terraform Integration
  • GitOps Workflows
  • Configuration Validation CI/CD
  • Lab: Automated Deployment Pipeline

Section 29: Capacity Planning

  • Load Testing Strategies
  • Capacity Forecasting
  • Resource Sizing
  • Benchmark Tools (wrk, ab, siege)
  • Stress Testing

Section 30: Operational Excellence

  • Disaster Recovery
  • Backup & Restore Procedures
  • Incident Response
  • Runbooks & Documentation
  • Zero-Downtime Upgrades
  • Final Lab: Production-Ready Load Balancer Setup

🎯 Learning Outcomes

After completing this course, you will be able to:

Design & deploy production-grade load balancing solutions
Optimize performance for high-traffic applications
Implement security best practices and SSL/TLS
Troubleshoot complex proxy & load balancing issues
Automate configuration and deployment workflows
Monitor & observe load balancer health and performance
Scale applications horizontally with confidence
Make informed decisions between Nginx and HAProxy


📋 Prerequisites

  • Basic Linux command-line knowledge
  • Understanding of networking concepts (TCP/IP, DNS, HTTP)
  • Familiarity with Docker (recommended)
  • Text editor skills (vim, nano, or any editor)

🛠️ Required Tools

  • Linux environment (Ubuntu/RHEL/Debian)
  • Docker & Docker Compose
  • curl, wget for testing
  • Optional: Kubernetes cluster for advanced labs

📝 Course Format

Each module contains:

  • Theory: Detailed explanations with examples
  • Configuration samples: Real-world configurations
  • Diagrams: Architecture and process flow illustrations
  • Labs: Hands-on exercises
  • Best practices: Production-ready recommendations
  • Troubleshooting guides: Common issues and solutions

🚀 Getting Started

Start with module-01-fundamentals.md and progress sequentially through the modules. Each module builds upon concepts from previous modules.


Happy Learning! 🎉

About

lectures-nginx-haproxy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors