Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.
SecurityCritical

Serve all pages over HTTPS

Every page and resource on your site must be delivered over HTTPS to protect user data in transit and enable modern browser features.

Utilities
Quick take
Typical fix time 30 min
  • All HTTP traffic must redirect to HTTPS with a 301 (permanent) redirect
  • TLS certificates must be valid, not expired, and cover all hostnames (including `www`)
  • HTTPS is a prerequisite for HSTS, HTTP/2, Service Workers, geolocation, and other modern APIs
  • Use a free certificate from Let's Encrypt or your hosting provider's managed TLS
  • Verify the certificate chain with SSL Labs (ssllabs.com/ssltest) — aim for A or A+
Why it matters: Plain HTTP exposes every request and response to anyone on the network path — ISPs, Wi-Fi operators, and MITM attackers can read passwords, session tokens, and personal data without any warning to the user.

Rule Details

HTTPS (opens in new tab) (HTTP over TLS) encrypts all traffic between the browser and your server, providing confidentiality, integrity, and authentication. MDN's transport security guidance (opens in new tab) and the OWASP transport cheat sheet (opens in new tab) both treat site-wide HTTPS as the baseline, not an optional hardening step.

Code Example

Let's Encrypt (Free)

# Install Certbot
sudo apt install certbot python3-certbot-nginx  # Debian/Ubuntu
sudo yum install certbot python3-certbot-nginx  # RHEL/CentOS
 
# Obtain and auto-configure certificate for Nginx
sudo certbot --nginx -d example.com -d www.example.com
 
# Certbot automatically sets up renewal
# Test renewal with:
sudo certbot renew --dry-run

Hosted / Managed TLS

Most platforms handle TLS automatically:

  • Vercel: Automatic — certificates provisioned for all deployments
  • Netlify: Automatic — one-click HTTPS via Let's Encrypt
  • AWS CloudFront: Use AWS Certificate Manager (free for CloudFront)
  • Cloudflare: Managed TLS included on all plans

Why It Matters

Plain HTTP exposes every request and response to anyone on the network path — ISPs, Wi-Fi operators, and MITM attackers can read passwords, session tokens, and personal data without any warning to the user.

What HTTPS Provides

  • Confidentiality: Data cannot be read by third parties on the network path
  • Integrity: Data cannot be modified in transit (prevents content injection by ISPs or MITM attackers)
  • Authentication: The certificate proves the server is who it claims to be, preventing impersonation

HTTP-to-HTTPS Redirect

Nginx

# Redirect all HTTP to HTTPS
server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://$host$request_uri;
}
 
server {
    listen 443 ssl http2;
    server_name example.com www.example.com;
 
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
 
    # ...
}

Apache

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>

Cloudflare

In the Cloudflare dashboard → SSL/TLS → Edge Certificates → enable Always Use HTTPS and set Minimum TLS Version to 1.2.

Modern Features Requiring HTTPS

Both MDN (opens in new tab) and web.dev (opens in new tab) treat these as secure-context features, so they are a practical way to spot pages that still rely on insecure origins.

Browsers block these APIs on non-secure origins:

FeatureWhy It Requires HTTPS
Service WorkersPrevent network interception of cached resources
Push NotificationsAuthentication required
Geolocation APIPrivacy protection
getUserMedia (camera/mic)Privacy protection
Web Crypto APISecurity requirement
Payment Request APIFinancial data protection
HSTS, HTTP/2, HTTP/3Protocol requirements
Mixed Content Breaks HTTPS

If your HTTPS page loads any resource over HTTP, the page is considered mixed content. Active mixed content such as scripts and iframes is blocked outright, so audit resource URLs and ensure they use HTTPS.

Common Pitfalls

MistakeImpactFix
Expired certificateBrowser blocks the page with a security warningConfigure auto-renewal (e.g., certbot renew via cron)
Certificate missing wwwwww.example.com shows a security errorUse a SAN certificate covering both example.com and www.example.com
HTTP redirect uses 302Browsers may not cache the redirect, slowing future requestsUse 301 (permanent) redirect
HTTPS only on login pagesData on all other pages exposed in transitEnable HTTPS site-wide

Exceptions

  • Local development or internal-only environments can differ, but production user-facing traffic should still satisfy the transport requirement strictly.
  • A redirect or HTTPS control that fails on one hostname, subdomain, or CDN edge path is still a real failure for users and crawlers reaching that surface.
  • Fix the strongest transport weakness first instead of treating every downstream symptom as a separate primary issue.

Support Notes

  • Verify HTTPS behavior in a production-like environment with the real certificate chain, redirects, proxies, and CDN path in place.
  • Modern secure-context features may appear to work locally while still failing or degrading on real production hosts.

Verification

Automated Checks

  • Run an automated security check, scripted probe, or log-based validation against a representative live flow.

Manual Checks

  • Verify the browser or user-facing behavior manually in a production-like flow and confirm there is no stronger conflicting security signal.

Use with AI

Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.

Check

Verify implementation

Check whether all pages of this website are served over HTTPS. Verify the TLS certificate is valid, not expired, and covers all hostnames. Confirm HTTP requests redirect to HTTPS with a 301 status code.

Fix

Auto-fix issues

Configure the web server to obtain a TLS certificate (e.g., via Let's Encrypt/Certbot), redirect all HTTP requests to HTTPS with a 301 redirect, and ensure all internal links and resources use HTTPS URLs.

Explain

Learn more

Explain why serving pages over HTTPS is essential for security, what happens when plain HTTP is used, and how to obtain and configure a TLS certificate.

Review

Code review

Review server config, headers, forms, and integration points related to Serve all pages over HTTPS. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

Mozilla Observatory
observatory.mozilla.orgTool

Rules that often go hand-in-hand with this one.

Redirect HTTP to HTTPS

All HTTP requests must be permanently redirected (301) to HTTPS to prevent users from accessing your site over an insecure connection.

Security
Submit forms over HTTPS

All HTML form actions must point to HTTPS URLs to ensure form data is encrypted in transit and cannot be intercepted by network attackers.

Security
Avoid mixed content on HTTPS pages

An HTTPS page that loads resources over HTTP has mixed content — browsers block or warn about these requests, breaking functionality and undermining transport security.

Security
Set a Referrer-Policy header

The Referrer-Policy header controls how much referrer information is sent when navigating from your site to another, protecting user privacy and preventing leaking sensitive URL parameters.

Security

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385