Php judges whether it is https or not.

on the Internet, many methods of judging https are stereotyped.
mainly judges
reference links from $_ SERVER to
https://blog.csdn.net/river13.
https://codeshelper.com/q/10.

.

but now nginx has done reverse proxy
$_ SERVER without the following parameters:
HTTPS
HTTP_X_FORWARDED_PROTO
HTTP_FRONT_END_HTTPS

not even SERVER_PORT is 443

how to judge https?


these things that need to be received in nginx plus header,php are all upstream. If nginx doesn't give it to you, php can't get these things.


is your https implemented in php or in nginx?


add a configuration in nginx proxy_set_header X-Forwarded-Proto $scheme; send the protocol used by the frontend to the backend, and your backend can judge based on this request header.

Menu