Question

How to detect the request protocol (HTTP or HTTPS) in a App Platform's Web Service Component?

Posted November 9, 2021 28 views
NginxPHPDigitalOcean App Platform

App Platform reverse proxies the requests to the Components but always to the same port, making it impossible to differ the request’s protocol used by just checking whether was the port 443 or 80 that received the request.

For exemple, NGINX allows us to use the Forwarded header to carry that information through a proxy thus letting or application check the protocol originally used to make the request.

Others also work with the X-Forwarded-Proto header with some other headers to carry that information through a proxy, but this one doesn’t seem to work.

That said, how could I check via PHP inside my component (running NGINX + PHP-FPM) which was the protocol originally used to make the request?

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!