locked
rewrite only 1 single page RRS feed

All replies

  • User-848649084 posted

    Hi,

    You could try to use a match pattern like below in rule:

     <rule name="ReverseProxyInboundRule5" enabled="true" stopProcessing="true">
                        <match url="^$" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{HTTP_HOST}" pattern="external.domain.com" />
                            <add input="{HTTPS}" pattern="on" />
                        </conditions>
                        <action type="Rewrite" url="http://internal.domain/local/page.php" logRewrittenUrl="true" />
                    </rule>

    ^$ only math the domain name after that all the requested URL will not allow tp to rewrite the URL.

    Note: the above mentioned rule is just an example you could modify rule based on your requirement.

    Regards,

    Jalpa

    Wednesday, February 12, 2020 2:14 AM
  • User732235148 posted

    I was  getting a 500 internal server error... After I removed my 'default'outbound rewrite rules, the page displays, but any graphis etc are missing. 

    So I'm half-way :)

     

    Wednesday, February 12, 2020 7:29 AM
  • User-848649084 posted

    Could you please share your web.config file and the browser snapshot?

    Thursday, February 13, 2020 1:23 AM
  • User732235148 posted

    OK, here we go :)

    First: this is what the page should normally look:

    https://imgur.com/KoWKvuX

    This is how it looks without any outbound rule defined

    https://imgur.com/MW8rsbG

    And with my default outbound rules (as in: used on 10 other sites)

    https://imgur.com/V8z6lLO

    And this is the complete rule that goes with the above error 500

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    	<system.webServer>
    		<rewrite>
    			<rules>
    				<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
                        <match url="^$" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{HTTP_HOST}" pattern="external.domain.com" />
                            <add input="{HTTPS}" pattern="on" />
                        </conditions>
                        <action type="Rewrite" url="http://internal.domain.local/page.php" logRewrittenUrl="true" />
                    </rule>
    			</rules>
    			<outboundRules>
    				<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
    					<match filterByTags="A, Form, Img" pattern="^http(s)?://internal.domain.local/(.*)" />
    					<action type="Rewrite" value="https://external.domain.com/{R:2}" />
    				</rule>
    				<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
    					<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
    					<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
    				</rule>
    				<rule name="Deal with href tags" preCondition="ResponseIsHtml1">
    					<match filterByTags="None" pattern="href=(.*?)http://internal.domain.local/(.*?)\s" />
    					<action type="Rewrite" value="href={R:1}https://external.domain.com/{R:2}" />
    				</rule>
    				<rule name="Deal with action tags" preCondition="ResponseIsHtml1">
    					<match filterByTags="None" pattern="action=(.*?)http://internal.domain.local/(.*?)\\" />
    					<action type="Rewrite" value="action={R:1}https://external.domain.com/{R:2}\" />
    				</rule>
    				<preConditions>
    					<preCondition name="ResponseIsHtml1">
    						<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
    					</preCondition>
    					<preCondition name="NeedsRestoringAcceptEncoding">
    						<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
    					</preCondition>
    				</preConditions>
    			</outboundRules>
    		</rewrite>
    	</system.webServer>
    </configuration>

    Thursday, February 13, 2020 7:58 AM
  • User-848649084 posted

    Could you please share what is the old rule? Generate Failed request tracing and get the detail where you failed. Generally, this error occurred when did not find the requested content.

    You should be able to see the rewritten rule in the trace, try accessing the URL directly to see if you get the 500.

    Also, check the IIS logs on both the IIS and ARR servers to see on which one the 500 is happening.

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

    Thursday, February 13, 2020 8:25 AM
  • User732235148 posted

    I have no old rule. This is a new setup. I just copied a web.config from one of our active sites, and started bij replacing the inbound rule with the one that was published here (of course: making sure internal and external URL's are correct)

    When using only the inbound rule, and no outbound: the site displays obviously (?) without any refereced images etc.. (as the internal localtion is not translated)

    When using inbound + outbound rules there's the 500 error

    The internal site is accessible from the 'rewrite server' without any error.

    Will try to get some logs (I have limited access to the machine)

    Thursday, February 13, 2020 10:04 AM
  • User732235148 posted

    bump.. Nobody that can help me on this?

    Thursday, February 20, 2020 3:37 PM
  • User-2064283741 posted
    I'll bump back. Failed request tracing will tell you step by step which bits failed and why.
    Thursday, February 20, 2020 7:11 PM