在Enable HTTPS for a web app in Azure App Service中提到,Azure Java 應用程式可以直接將連線由http改為https即可,只是安全性不如使用自訂網域及自己的憑證那麼安全。
答案是可以的。
- 取得web.config的格式
從同篇文章中的段落 Enforce HTTPS on your web app,取得web.config的設定格式,rule內容不使用,稍後會說明。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https">
...
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
- 保留完整URL
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{REQUEST_METHOD}" pattern="^get$|^head$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
- 上傳web.config