-
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
mkcertto 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, andX-Real-IP. - Cache-control headers include
Cache-Control,Expires,ETag, andLast-Modified. - Security headers reduce attack surface and harden browsers against common threats.

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
X-Forwarded-For and X-Real-IP) so backend services can log and audit requests or perform IP-based logic correctly.
Recommended security headers (quick reference)
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.IP allow/deny directives and scaling considerations
NGINX supportsallow 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
- NGINX Official Site
- Let’s Encrypt
- mkcert — Simple Zero-CA for Development
- Certbot Documentation
- Fail2Ban Project