【发布时间】:2015-08-02 23:12:10
【问题描述】:
我正在尝试在运行在 tomcat 1.7 上的 Azure Java Web 应用程序上强制执行 https。 (应用程序是使用门户创建的) 我已将以下 web.config 添加到 site/wwwroot 目录。这是通过 https 正确重定向非 http 调用,但在应用程序内部,请求似乎具有 http 而不是 https。
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*"
verb="*" modules="httpPlatformHandler"
resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%AZURE_TOMCAT7_HOME%\bin\startup.bat">
</httpPlatform>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我认为应用程序显示 http 而不是 https 可能是标准行为,但我当然希望以下内容呈现真实
HttpServletRequest request
request.isSecure() //this should be true
request.getScheme() //Ideally should be https but is http
有什么我需要添加到我的 web.config 文件的吗?
不确定这是否有很大不同,但我使用的是 CA 签名的通配符证书,我也通过门户网站上传了该证书。这肯定是有效的,因为在我无法在我的网络应用程序上进行 https 调用之前以及在证书上传之后我能够进行调用。
提前感谢您的帮助。
【问题讨论】:
-
当您向您的网站发出 https 请求时会发生什么?请求在您的应用程序中仍然显示为 http 吗?
-
不,即使我直接点击它也是应用程序内部的http,当我调用isSecure()时仍然显示false
-
如果您在本地计算机上运行该站点,https 是否正确加载?
-
如果我将 tomcat 连接器安全属性设置为 true,这肯定会在本地传递。问题是如何在 Azure Web 应用程序上获取此设置,因为我们无法直接访问 tomcat 实例
-
如果您可以访问 tomcat 配置,那么将 secure="true" 和 scheme="https" 添加到 tomcat 连接器即可
标签: java azure iis ssl azure-web-app-service