我们在 WPEngine 上有一个启用了 SSL 的网站,因此每个页面都通过 https 提供服务。
我们最近切换到 Heroku 上的 Ruby on Rails。现在我们在使用 https 时出现了一些错误:
Your connection is not private
Attackers might be trying to steal your information from myapp.com (for example, passwords, messages, or credit cards). NET::ERR_CERT_COMMON_NAME_INVALID
当我执行 curl
检查我的自定义域或 herokuapp 域时,SSL 已通过验证。
curl -kvI https://myapp.herokuapp.com
# SSL certificate verify ok.
curl -kvI https://myapp.com
# SSL certificate verify ok.
Chrome 中的错误是:
This server could not prove that it is myapp.com; its security certificate is from *.herokuapp.com. This may be caused by a misconfiguration or an attacker intercepting your connection.
在我的 production.rb 中我有:
config.force_ssl = true
最佳答案
不久前,我们的 Java 应用程序也遇到了同样的问题。我可能是错的,但是 Heroku PaaS 在 dynos 后面有他们的云代理,默认情况下它会覆盖请求 header (在我们的例子中是从 https-to-http)。我想你可能有兴趣查看 X-Forwarded-For
header 。我们的解决方案是在 Procfile
中显式传递请求上下文参数。 .
Procfile 应该包含类似(对于 Java)的内容:
..--context-xml <contextWithHeaderOptions>..
实际 context.xml
:
<Context>
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="x-forwarded-for" protocolHeader="x-forwarded-proto" portHeader="x-forwarded-port"/>
</Context>
关于ruby-on-rails - SSL 证书 WPEngine 到 Heroku Rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32525688/