Skip to main content
This lesson recaps the critical concepts from the module, emphasizing practical security and operational best practices for serving web traffic. Use this concise reference to remember the most important points about HTTPS, certificates, reverse proxy behavior, headers, authentication, and access control.

HTTPS and redirects

  • Always serve sites over HTTPS whenever possible. Modern browsers may block or warn users about insecure HTTP pages and many web platform features require HTTPS.
  • Redirect plain http:// traffic to https:// at the proxy or web server level so users always receive the encrypted site.
  • Use HSTS (HTTP Strict Transport Security) to tell browsers to always connect over HTTPS after the first secure visit.
Example NGINX redirect (place in the server block listening on port 80):
Always enforce HTTPS and configure an HSTS policy (for example: Strict-Transport-Security: max-age=63072000; includeSubDomains; preload) only after you are confident all subdomains support HTTPS.

SSL vs TLS and certificate sources

  • TLS is the modern protocol that replaced the deprecated SSL family. People still say “SSL” colloquially, but TLS is the current, secure standard.
  • For local development, use mkcert to create locally trusted certificates. It installs a local CA into your machine so your browser trusts development certs.
  • For public-facing sites, obtain certificates from a trusted CA such as Let’s Encrypt (free) or commercial CAs like DigiCert and Comodo.
Table — certificate sources and typical uses:

HTTP headers and reverse-proxy behavior

Understanding which headers a reverse proxy sets or forwards is critical. Misconfigured headers can cause incorrect application behavior or security gaps.
  • Common proxy-forwarded headers:
    • X-Forwarded-For — original client IP
    • X-Forwarded-Proto — original protocol (http or https)
    • Host — requested host header
  • Make sure your backend application trusts and correctly parses these headers (or use a trusted proxy with header rewriting features).
Table — important security and caching headers:

Authentication: auth_basic and robust alternatives

  • NGINX auth_basic (HTTP Basic Auth) is simple to set up and useful for internal, staging, or temporary protection.
  • For public-facing apps, prefer stronger, auditable authentication methods such as OAuth2, OpenID Connect, or SSO providers integrated with your app or identity provider.
Do not use HTTP Basic Auth for production user-facing authentication. It lacks modern features like session management, multifactor authentication, and robust auditing.

Access control: allow/deny vs scalable protections

  • NGINX allow/deny directives are convenient for small, static IP-based access lists (for example, allowing a management subnet).
  • These rules do not scale well when you have many IPs or frequently changing lists.
  • For larger deployments, use centralized, scalable solutions:
    • Network firewalls and ACLs
    • Web Application Firewalls (WAF)
    • Automated blocklists or dynamic tools like Fail2Ban to detect abuse and update firewall rules
Tip: Fail2Ban can monitor logs and dynamically block abusive IPs, reducing manual maintenance for straightforward abuse patterns.

Operational recommendations

Combine layered controls for a secure, maintainable production environment:
  • Enforce TLS and implement strong HSTS policies once ready.
  • Set comprehensive security headers (CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy).
  • Ensure the reverse proxy forwards the correct X-Forwarded-* headers and your backend validates them.
  • Use automated tooling:
    • Let’s Encrypt (ACME) for certificate issuance and automated renewal
    • Fail2Ban, WAF, or cloud security services for blocking abuse
    • Infrastructure-as-code (Terraform, CloudFormation) for reproducible network and firewall rules

Quick checklist

  • Serve all production sites over HTTPS
  • Redirect HTTP to HTTPS at the proxy/web server
  • Use trusted certificates and automate renewals
  • Configure HSTS after verifying all subdomains support HTTPS
  • Harden with security headers and validate them in staging
  • Prefer OAuth/OpenID Connect for public authentication
  • Use scalable access controls for large or dynamic environments
  • Automate detection and blocking of abusive traffic (Fail2Ban/WAF)

Watch Video