确定访客是否通过CloudFlare Pro上的SSL连接 [英] Determine if visitor connected over SSL on CloudFlare Pro

查看:106
本文介绍了确定访客是否通过CloudFlare Pro上的SSL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在CloudFlare Pro上运行的网站,该网站使用其提供的证书进行一键加密。我们的网站为用户提供了可选 SSL。作为一个论坛,我们当前运行一个代理脚本,该脚本检测发布的图像是否未使用HTTPS协议,并通过服务器上运行的脚本自动代理该图像,以维护安全性和可爱的绿色锁!

We have a site running on CloudFlare Pro that uses their supplied certificate for one-click encryption. Our site has "optional" SSL for users. As it's a forum, we currently run a proxy script that detects if a posted image is not using a HTTPS protocol and automatically proxies the image through a script running on our server to maintain security and our lovely green lock!

我现在唯一的问题是,当用户不使用HTTPS时,这会在我们的服务器上引入不必要的负载,因此我们希望能够检测到它们是否存在。但是,由于CloudFlare服务器实际上是通过HTTP连接到我们的服务器,而不管通过HTTP进行什么连接(因为我们在CloudFlare上使用了一键式SSL),因此即使用户使用HTTPS,我们的PHP脚本也始终报告HTTP,并且从不代理图像。有没有办法让CloudFlare报告用户正在使用SSL?

My only issue now is that this introduces unnecessary load on our servers when users aren't using HTTPS so we would like to be able to detect if they are or are not. However, as the CloudFlare server is actually connecting to ours no matter what over HTTP (because we are using one-click SSL on CloudFlare) our PHP script always reports HTTP and never proxies the images even when the user is using HTTPS. Is there a way to get CloudFlare to report the user is using SSL?

推荐答案

找到我的答案,他们发送标题 X-FORWARDED-PROTO 。对于SSL,它为 https ,对于普通服务器,为 http

Found my answer, they send a header X-FORWARDED-PROTO. It's https for SSL and http for normal!

这篇关于确定访客是否通过CloudFlare Pro上的SSL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆