<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <!-- Set the X-Forwarded-For header to the value of the HTTP_X_FORWARDED_FOR server
                variable -->
                <add name="X-Forwarded-For" value="{HTTP_X_FORWARDED_FOR}" />
            </customHeaders>
        </httpProtocol>
        <security>
            <requestFiltering>
                <requestLimits maxQueryString="32768" maxUrl="65536"
                    maxAllowedContentLength="655360000" />
            </requestFiltering>
        </security>
        <rewrite>
            <rules>
                <rule name="HTTP to HTTPS Redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="API Proxy Rule" stopProcessing="true">
                    <match url="^api/(.*)" />
                    <action type="Rewrite" url="http://localhost:3004/{R:1}?reverse_proxy_client_ip={REMOTE_ADDR}&amp;client_domain={HTTP_HOST}" />
                </rule>
                 <rule name="tools" stopProcessing="true">
                    <match url="^tools/(.*)" />
                    <action type="Rewrite" url="http://localhost:4001/{R:1}?reverse_proxy_client_ip={REMOTE_ADDR}&amp;client_domain={HTTP_HOST}" />
                </rule>
                <rule name="ReactJS Redirect" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
        <staticContent>
            <mimeMap fileExtension=".brotli" mimeType="application/brotli" />
        </staticContent>
    </system.webServer>
    <system.web>
        <httpRuntime maxRequestLength="2097151" maxUrlLength="65536" maxQueryStringLength="2097151" />
    </system.web>
</configuration>