Reputation: 31
I am trying to enforce https on an Azure java web app running on tomcat 1.7. (The application wa created using the portal) I have added the below web.config to the site/wwwroot directory. This is correctly redirecting the non http calls via https, but inside the application the request appears to have a http rather than 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>
I think it might be standard behavior for the application to be showing http rather than https, but i was certainly expecting the below to render true
HttpServletRequest request
request.isSecure() //this should be true
request.getScheme() //Ideally should be https but is http
Is there anything I need to add to my web.config file?
not sure if it makes much difference but I am using CA signed wild card certificate which I have also uploaded through portal. This is definately working becasue before I couldnt make https calls on my web app and after the certificate upload I was able to make the calls.
Thanks in advance for your help.
Upvotes: 0
Views: 1558
Reputation: 152
Just to answer the problem domain of editing configuration, there are 3 methods of using Java with Azure App Service:
1) enable through the portal. This method is great when uploading a war file but you cannot change configuration for the web container.
2) deploy Tomcat or Jetty from the Marketplace/gallery. When you do this you get a complete install of Tomcat or Jetty in your space that you can edit or alter to your hearts content
3) upload a custom app including your own jvm if desired. If you go this route there are a few things you need to keep in mind that are described in the Azure documentation.
With respect to SSL, due to the need in App Service to support a multitude of frameworks, SSL is supported upstream of the app. You don't need to enable the HTTPS connector in Tomcat or locally set a trust store or any of those fun things. Use the information here: http://azure.microsoft.com/en-us/documentation/articles/web-sites-configure-ssl-certificate/ to enable HTTPS for your site.
Upvotes: 1