Page 1 of 1

IIS rewrite 400 error

PostPosted: Sun May 06, 2018 8:54 pm
by Bandit1157
Hi all, I'm using IIS 10 on a separate web server to send mediabrowser requests to my serviio server (both Windows Server 2016 VMs on the same physical server/network and my public domain and private windows domain are the same). I'm using Url Rewrite 2.0 with rules for both the /mediabrowser and /cds paths that work fine. The only problem I've been having is viewing certain content, namely the list of episodes of a TV series. The page fails to load completely and gives the below 400 error. It looks like it might be caused by the ^ and * symbols in the url (which would understandably mess up regex matching), but when I check the failed request logs in IIS it looks like it's matching and rewriting the url correctly. I'm a complete noob to url rewriting and have searched this forum and elsewhere extensively to try and figure out what's going on. Some online sources said this could be caused by IIS security settings, which I tried tweaking with some registry changes to no avail.

Anyway I've included the webconfig below, appreciate any help!


Serviio 400 error.png
Serviio 400 error.png (91.78 KiB) Viewed 7315 times


  Code:
        <rewrite>
            <rules>
                <rule name="Serviio Inbound" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://serviio.mydomain.net:23424/{R:1}" logRewrittenUrl="true" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{PATH_INFO}" pattern="mediabrowser" />
                        <add input="{PATH_INFO}" pattern="cds" />
                    </conditions>
                </rule>
            </rules>
            <outboundRules>
                <rule name="Serviio Outbound" preCondition="ResponseIsHtml1" patternSyntax="ECMAScript" stopProcessing="true">
                    <match filterByTags="A, Form, Img, Link" pattern="^http://serviio.mydomain.net:23424/(.*)" />
                    <action type="Rewrite" value="https://media.mydomain.net/{R:1}" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{PATH_INFO}" pattern="mediabrowser" />
                        <add input="{PATH_INFO}" pattern="cds" />
                    </conditions>
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>

Re: IIS rewrite 400 error

PostPosted: Sun May 06, 2018 9:19 pm
by bolzass
Hi!,
No idea about IIS (more experienced in rewriting with apache); but what I can remember with that, take care about https/http at rule.
I saw https in your config. Test http, change it, and be careful with the port ("4" for the 1st one and "5" with the 2nd one).

Good luck!
.

Re: IIS rewrite 400 error

PostPosted: Sun May 13, 2018 7:06 am
by heuby
Hi,
I know, not the answer you searched, but I have the same problem and cannot found a solution for it.
But, I came to the same conclusion as you.

viewtopic.php?f=5&t=24271&p=116264

If you can find a solution, please post it here.

Re: IIS rewrite 400 error

PostPosted: Mon May 14, 2018 8:00 pm
by Bandit1157
Think this might be an ASP configuration issue. I know next to nothing about interpreting the IIS rewrite logs but it looks like ASP is incorrectly parsing the URL text. I'll try posting this on one of the IIS forums and report back with a solution once I figure it out.

Re: IIS rewrite 400 error

PostPosted: Tue May 15, 2018 3:58 pm
by Bandit1157
heuby wrote:Hi,
I know, not the answer you searched, but I have the same problem and cannot found a solution for it.
But, I came to the same conclusion as you.

viewtopic.php?f=5&t=24271&p=116264

If you can find a solution, please post it here.


So I ended up running the reverse proxy on haproxy. I use pfSense for my firewall and this was relatively straightforward to set up. If you have this as an option I'd be happy to send you my config. I was using IIS for the reverse proxy because I'm using an SSTP VPN for remote access and IIS automatically distinguishes VPN traffic from HTTPS traffic, but I'm transitioning to OpenVPN because of the higher security.

I poked around on the IIS forum but I need to do more troubleshooting before I can begin asking questions there (as I mentioned before, I can't do web programming worth crap!). Not sure when I'll get around to this, but if I figure it out I'll definitely post a how-to here.

Re: IIS rewrite 400 error

PostPosted: Wed May 16, 2018 4:56 am
by heuby
Sounds good, but for me pfSense isn't a possible way. I use IP-TV from my ISP, that is not properly working behind pfSense.
Possible your solution works in other environments.

Thank you

Re: IIS rewrite 400 error

PostPosted: Sun Jun 03, 2018 7:02 am
by heuby
I have found the solution and post it here (last message):

viewtopic.php?f=5&t=24271&p=117895#p117895

:D