X-Forwarded-Proto Header Explained

What the HTTP X-Forwarded-Proto header does and when it's used.

Published October 15, 2026

X-Forwarded-Proto tells the backend whether the client's original connection used http or https, since TLS is often terminated at a proxy.

How it works

Without it, apps think every request is HTTP and may generate wrong redirects or insecure links.

The X-Forwarded-Proto header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
X-Forwarded-Proto: https
Where X-Forwarded-Proto appears.

Practical examples

The header

X-Forwarded-Proto: https

Set or use it in code

proxy_set_header X-Forwarded-Proto $scheme;

Inspect it

curl -sI https://example.com | grep -i 'x-forwarded-proto'

Common mistakes

  • Redirect loops from HTTP/HTTPS confusion
  • Not trusting the proxy header in the framework
  • Generating http:// URLs in HTTPS pages

Key takeaways

  • X-Forwarded-Proto: X-Forwarded-Proto tells the backend whether the client's original connection used http or https, since TLS is often terminated at a proxy.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Why is my app redirecting forever?

It sees HTTP because the proxy did not pass or the app did not trust X-Forwarded-Proto.

Is X-Forwarded-Proto case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles