我很难在我可伸缩的OpenShift PHP应用程序上获取基本的HTTP身份验证。在我的.htaccess文件中我有:

AuthUserFile path/to/.htpasswd
AuthType Basic
AuthName "My App"
Require valid-user
.

这在我的本地测试服务器上有很好的工作,但是当我尝试在OpenShift上使用它时,我可以获得503服务,不可用,在我的haproxy.log中我得到:

[WARNING] 101/113040 (368468) : Server express/local-gear is DOWN, reason: Layer7 wrong status, code: 401, info: "Authorization Required", check duration: 2ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 101/113040 (368468) : proxy 'express' has no server available!
.

所以我想问题必须与haproxy服务器一起,但我没有clue如何解决它。任何想法?

非常感谢!

有帮助吗?

解决方案

您需要有一个haproxy可以访问的URL,否则它将抛出503个错误。如果您想要up.html页面,请从您的.htpasswd设置中排除它,然后更改您的haproxy / haproxy.cfg以轮询URL而不是/ p>。

此外,如果.htpasswd文件未存储在git repo中,那么它将不会被复制到缩放应用程序中的每个档。如果它位于您的git repo中,因此在您的Web访问文件夹中,那么这是不安全的。

其他提示

haproxy提供了一个将某个URL视为SanityCheck的功能。 OpenShift默认情况下启用此功能。 确保它指向正确的URL,或通过更改〜/ haproxy / conf / haproxy.cfg:

来禁用它
option httpchk GET /
.

进入

#option httpchk GET /
.

在这个 openshift线程

中阅读更多

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top