Skip to main content
This lesson covered practical, production-ready ways to secure web traffic when using a reverse proxy (NGINX) and how to pass correct client information to backend services. Below is a concise recap of the key topics, best practices, and concrete configuration examples you can apply to your deployments.
  • HTTPS and redirects
    • Always serve public sites over HTTPS — browsers may warn or block non-HTTPS sites.
    • Enforce HTTPS by redirecting HTTP to HTTPS at the web server or reverse proxy level to ensure all users automatically use the secure site.
  • SSL and TLS
    • Use TLS (the modern protocol) rather than older SSL versions.
    • For local development, use tools like mkcert to create locally trusted certificates; plain self-signed certs are typically marked untrusted by browsers.
    • For production, obtain certificates from trusted CAs such as Let’s Encrypt (free) or commercial providers like DigiCert or Comodo.
  • HTTP headers — why they matter
    • HTTP headers control content negotiation, caching, and security behaviors. Properly configured headers are essential for reverse proxies, load balancers, and web servers.
    • Reverse proxies commonly forward these headers to backends: Host, X-Forwarded-For, X-Forwarded-Proto, and X-Real-IP.
    • Cache-control headers include Cache-Control, Expires, ETag, and Last-Modified.
    • Security headers reduce attack surface and harden browsers against common threats.
A presentation summary slide with a blue gradient sidebar titled "Summary" and four numbered items. The items list topics about securing websites: HTTPS, SSL/TLS certificates, types of HTTP headers, and use cases for HTTP headers.

Reverse proxy use cases

Reverse proxies are commonly used for:
  • TLS termination (offloading TLS from backends)
  • Request routing and virtual hosting
  • Load balancing and health checks
  • Injecting or forwarding headers so backends receive correct client context
Always ensure your reverse proxy forwards client-identifying headers (for example, X-Forwarded-For and X-Real-IP) so backend services can log and audit requests or perform IP-based logic correctly. Include security headers at the reverse-proxy layer when possible so they apply consistently across backend services.

Authentication and access control with NGINX

NGINX provides simple server-side authentication and access control primitives suitable for internal or limited-access services. Example: HTTP Basic auth (suitable for small-scale internal use)
Avoid using auth_basic for external/public authentication where modern identity providers (OAuth, SSO) are more appropriate.
For public-facing applications, prefer integrated identity solutions (OAuth2, OpenID Connect, SAML, or an SSO provider) which provide stronger authentication, centralized management, and features like multi-factor authentication.

IP allow/deny directives and scaling considerations

NGINX supports allow and deny directives for simple IP/CIDR-based access controls:
  • Useful for small, static lists (e.g., internal admin panels restricted to a corporate subnet).
  • Not recommended as the primary defense for large-scale or automated responses — maintaining long lists is error-prone.
  • For automated or large-scale blocking, use tools like Fail2Ban to monitor logs and manage dynamic bans.

Operational recommendations (checklist)

  • Enforce HTTPS and redirect HTTP traffic to HTTPS at the proxy layer.
  • Use HSTS and other security headers in production.
  • Automate certificate issuance and renewal (for example, use Certbot with Let’s Encrypt).
  • Consistently forward client headers (X-Forwarded-For, X-Forwarded-Proto, Host) to backends to preserve client context.
  • Prefer centralized identity providers (OAuth, SSO) for public authentication needs.
  • Use Fail2Ban or WAF systems for dynamic protection and automated blocking of abusive IPs.
  • Regularly audit header sets and CORS/CSP policies to ensure you’re not inadvertently exposing sensitive capabilities.

Additional references

That wraps up this article. Thanks for reading.

Watch Video