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

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

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I did a test and found the following headers to be set by the proxy (IPs faked) for my HTTPS endpoint:

x-forwarded-proto: https
cdn-loop: cloudflare

Note that the headers are sent lower-case.