<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <!-- PHP 8.3 FastCGI -->
    <handlers accessPolicy="Read,Execute,Script">
    </handlers>

    <!-- URL Rewrite to index.php -->
    <rewrite>
      <rules>
                <clear />
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{CACHE_URL}" pattern="^(https?)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://magister.aisuport.ro/{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_PROXY_AUTH" value="MAGISTER_AD" />
                    </serverVariables>
                </rule>

        <!-- Redirect to HTTPS -->
        

        <!-- Main Rewrite -->
        

      </rules>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
    </rewrite>

    <!-- Default document -->
    <defaultDocument>
      <files>
        <add value="index.php" />
      </files>
    </defaultDocument>

    <!-- Upload max 50MB -->
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="52428800" />
      </requestFiltering>
            <authentication>
                <anonymousAuthentication enabled="true" />
            </authentication>
    </security>

    <!-- FIX Authorization header -->
    <httpProtocol>
      <customHeaders>
        <add name="Authorization" value="{HTTP_AUTHORIZATION}" />
      </customHeaders>
    </httpProtocol>

    <!-- Debug -->
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true" />

  </system.webServer>
    <system.web>
        <authentication mode="Windows" />
    </system.web>
</configuration>
