Redirect Subfolder to Apache on VM [Answered]RSS

4 replies

Last post May 13, 2019 03:11 PM by RockNLol

  • Redirect Subfolder to Apache on VM

    Feb 14, 2019 10:39 PM|RockNLol|LINK

    hi,

    I'm trying to setup a horde groupware instance on a debian-VM, which is not publicly accessible. Horde naturally wants to be accessible on example.com/horde. example.com in my case is a website in IIS on my Windows Server 2012. So far I tried a Reverse Proxy URL-Rewrite rule:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <outboundRules>
                    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^http(s)?://apache.on.the.local.network/horde/(.*)" />
                        <action type="Rewrite" value="http{R:1}://example.com/{R:2}" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                        <match url="(.*)" />
                        <action type="Rewrite" url="http://apache.on.the.local.network/horde/{R:1}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

    which gets me a 404 Not Found Error from Apache, saying that the requested /horde/horde/login.php wasn't found. Obviously because /horde is in there twice. Leaving /horde out of the rule results in no /horde at all and landing on the apache test site. What am I doing wrong here?

    Also for ActiveSync to work I need IIS to redirect example.com/Microsoft-Server-ActiveSync as well as example.com/autodiscover/autodiscover.xml to be redirected (proxied?) to apache.on.the.local.network/horde/rpc.php. How do I do that?

    Thanks in advance!

  • Re: Redirect Subfolder to Apache on VM

    Feb 15, 2019 05:33 AM|lextm|LINK

    You might change this part (remove horde from action tag, and also add a condition to verify if horde presents in URL)

    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                        <match url="(.*)" />
                        <action type="Rewrite" url="http://apache.on.the.local.network/horde/{R:1}" />
                    </rule>
    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Redirect Subfolder to Apache on VM

    Feb 15, 2019 06:26 AM|Jalpa Panchal|LINK

    Hi,

    Try to run Failed request tracing and check how your rule is working.

    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules 

    post your FRT result.

    Regards,

    Jalpa.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Redirect Subfolder to Apache on VM

    Feb 15, 2019 10:59 AM|RockNLol|LINK

    Unfortunately I don't have ASP.NET on the apache server, so I'm afraid that won't work. At least I did not get it to work properly.

    My new edited Rule looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <outboundRules>
                    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^http(s)?://apache.local/(.*)" />
                        <action type="Rewrite" value="http{R:1}://iis.local/{R:2}" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                        <match url="horde(.*)" />
                        <action type="Rewrite" url="http://apache.local/{R:0}" logRewrittenUrl="true" />
                    </rule>
                </rules>
            </rewrite>
            <urlCompression doStaticCompression="true" doDynamicCompression="true" />
            <httpErrors errorMode="Detailed" />
        </system.webServer>
    </configuration>

    Is that what you meant, lextm? This results in a 404.0 (found your blog lextm smile, and saw that I put a / in front of the match tag) This now redirects me to http://apache.local/ and not to http://apache.local/horde, even though the rewritten URL looks correct in the pattern test from IIS. I activated the option to log rewritten URLs but there is nothing corresponding to the rewriting in the logfiles, only GET requests from my testing.

  • Re: Redirect Subfolder to Apache on VM

    May 13, 2019 03:11 PM|RockNLol|LINK

    hi!

    Since I couldn't get nextcloud to work either as described here, I switched to haproxy on a Debian Hyper-V VM which does my reverse proxying now. This now works flawlessly and was not hard to set up.