Search code examples
.netangularhttpsdeploymentiis-7.5

IIS 7.x server error with HTTPS deployement


Am using IIS V7.5 with windows server for deploying Angular + .Net 4.5 fullStack application.

Am using multiple instances at same site with different versions of application in order to make additional test !

all sites are deployed on same host with https and different ports each for frontend and backend (frontend part and backend part are deployed seperately ) as shown below :

Architecture of deployement

Before two months : all instance were deployed all as same structure but using http for all , and nothing happened ( everthing is working fine )

my problem is , when i changed instances to use https , of course with changing build for appropriate link , i get errors and frontend can't communicate with backend anymore ! is it a problem related to IIS and https and multiple instances ?


Solution

  • As a solution for this issue , as so many developpers can face it in the future : I have changed to file Web.config (XML File ) inside the folder dist of the build of the frontend part before deplyoing it on iis :

        <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    
    
    
    <!--START REDIRECT TO HTTPS-->
    <rule name="Redirect to https" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
    </rule>
    <!--END REDIRECT TO HTTPS-->
    
    
    
    <!--START REDIRECT TO ROOT-->
    <rule name="Angular routes" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
    <add input="{REQUEST_URI}" pattern="^/(token)" negate="true" />
    <add input="{REQUEST_URI}" pattern="^/(userguide.cshtml)" negate="true" />
    </conditions>
    <action type="Rewrite" url="/" />
    </rule>
    <!--END REDIRECT TO ROOT-->
    
    
    
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

    Note : For IIS version 7.x.x and 6.x.x and windows Server 2012 R2 This error is confirmed .