IIS Reverse Proxy Module 500 error when going to PHP backend

/ May 13th, 2013/ Posted in IIS, Server / 1 Comment »

Problem:
When setting up IIS reverse Proxy to connect back to a linux PHP application the site would not load and IIS would throw a 500 error. When browsing to the PHP site from the IIS server manually no errors and connectivity was working fine.

Solution:
I missed an option in the web.config file for the PHP pattern “pattern=”^text/php”” :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <rewrite>
        <outboundRules>
          <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
            <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://10.0.xxx.81/(.*)" />
            <action type="Rewrite" value="http{R:1}://www.xxxx.com/{R:2}" />
          </rule>
          <preConditions>
            <preCondition name="ResponseIsHtml1">
              <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
	      <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/php" />
            </preCondition>
          </preConditions>
        </outboundRules>
        <rules>
                <clear />
                <rule name="index" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
                    </conditions>
                    <action type="Redirect" url="http://www.xxxx.com/xx/slovenia/index.php" />
                </rule>
                <rule name="ReverseProxyInboundRule1" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                    </conditions>
                    <action type="Rewrite" url="http://10.0.xxx.81/bd/slovenia/{R:0}" />
                </rule>
        </rules>
      </rewrite>
        </system.webServer>
</configuration>

One Comment

  1. Ben
    2013/06/11 at 07:25:36

    Thanks!

Leave a Reply

Name required

Please Submit Answer * Time limit is exhausted. Please reload CAPTCHA.