I have a load balancing environment on AWS powered by Elastic Beanstalk. The SSL certificate is applied on the load balancer. To force https redirects, i have followed the accepted andswer in this post Redirect to https through url rewrite in IIS within elastic beanstalk's load balancer. These are the exact lines of code which i have written in web.config
<rewrite>
<rules>
<rule name="Force Https" stopProcessing="true">
<match url="healthcheck.html" negate="true" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
But this causes the environment health to become red within 5 minutes of publish and website starts giving 503 errors. If i remove them, then there are no errors. Kindly help me fix this menace so that https redirection is successful. In the first 5 mins after the publish, http requests are successfully redirected to https. Only after that 503 error starts coming.