在PHP中检测HTTPS请求 [英] Detecting HTTPS requests in PHP

查看:317
本文介绍了在PHP中检测HTTPS请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我遇到的问题与需要不断通过HTTPS,其余踢HTTP保护的网站的某些URL做。

The problem that I am having has to do with the need to keep some urls of a website protected by HTTPS and the rest kicked to HTTP.

通常情况下,你有 $ _ SERVER ['HTTP_HTTPS'] $ _ SERVER ['HTTPS'] (视在你的Apache的味道)。您还可以检查端口 - 这是80正常流量和443 HTTPS。

Normally, you have $_SERVER['HTTP_HTTPS'] or $_SERVER['HTTPS'] (depending on your flavor of Apache). You also can check the port - it's 80 for normal traffic and 443 for HTTPS.

我的问题是,在证书坐在负载均衡器,而所有这些变量是不可用,Web服务器看到的 http://www.foo.com 80端口上解决这个问题是告诉负载均衡器发送一个不同的端口流量的一种方法,但我不知道是否有其他的方法来检测HTTPS从负载平衡器来了吗?

My problem is that the certificate sits on the loadbalancer, and all these variables are unavailable, and the webserver sees http://www.foo.com on port 80. One way to fix this is to tell the loadbalancer to send the traffic on a different port, but I wonder if there are other ways to detect HTTPS coming from the load balancer?

推荐答案

如果负载平衡器是SSL连接的另一端,你不能得到任何比负载平衡器明确规定更多的信息。我会去增加一个HTTP头,它可能已经这样做,倾倒所有的HTTP标头和期待。

If the load balancer is the other end of the SSL connection, you cannot get any more info than the load balancer explicitly provides. I would go for adding a http header, it may already be doing that, dump all the HTTP headers and look.

另外,也可以做基于URL负载平衡器重定向。

As another solution, you can do the redirection on the load balancer based on URL.

这篇关于在PHP中检测HTTPS请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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