URL Rewrite redirect to the port 80 not port 8080 on Internal web serverRSS

8 replies

Last post Jul 18, 2017 08:11 AM by Yuk Ding

  • URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 12, 2017 03:58 PM|KaneW|LINK

    Hi;

    I want to redirect the internet traffice for http://www.company.com/uat to my internal test web server http://wwwtest.company.local:8080 but my script below direct me to the web site which is assigned port 80 on host http://wwwtest.company.local, why?  I am very happy if anyone of you can point me out the problem, I am new to configure the ARR and URL Rewrite.

    I have a ARR server in front the internal web server.  I created a site on ARR server and created a URL Rewrite inbound rule on ARR IIS.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <outboundRules>
    <rule name="OutboundReverseProxy" preCondition="IsHTML">
    <match filterByTags="A" pattern="^/(.*)" />
    <conditions>
    <add input="{URL}" pattern="^/(uat|dev)/.\*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/{R:1}" />
    </rule>
    <preConditions>
    <preCondition name="IsHTML">
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
    </preConditions>
    </outboundRules>
    <rules>
    <rule name="uat_inbound" stopProcessing="true">
    <match url="(.*)/uat" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="wwwtest.company.local" />
    </conditions>
    <action type="Redirect" url="http://wwwtest.company.local:8080" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 13, 2017 02:44 AM|Yuk Ding|LINK

    Hi KaneW,

    I think you redirect rule is completely wrong. If you need to redirect http://www.company.com/uat to http://wwwtest.company.local:8080, here is the modified rule:

    <rule name="uat_inbound" stopProcessing="true">
     <match url="uat" />
     <conditions>
                            <add input="{HTTP_HOST}" pattern="www.company.com" />
     </conditions>
     <action type="Redirect" url="http://wwwtest.company.local:8080" />
     </rule>

    Keep in mind that the <match url> element start from means the sub-path instead of the whole URL with host name. So in http://www.company.com/uat match url means uat instead of www.company.com/uat. In addition, the varaibale {URL} means /uat with back slash. Besides, the {HTTP_HOST} should be modified to www.company.com instead of wwwtest.company.local.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 13, 2017 04:26 PM|KaneW|LINK

    .

  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 13, 2017 09:53 PM|KaneW|LINK

    Thanks Yuk Ding;

    I modified the syntax to make it work like this.

    But to make it work, I have to uncheck "Use URL Rewrite to inspect incoming requests" in Routing Rules of the server in server farms.  Do you know why?

    And I cannot see any data in "Monitoring and Management" of server farms.

    <rule name="uat_inbound" stopProcessing="true">
     <match url="uat" />
     <conditions>
          <add input="{HTTP_HOST}" pattern="www.company.com" />
    </conditions>

    <action type="Rewrite" url="http://wwwtest.company.local:8080" />
    </rule>

    <rule name="DEV_inbound" stopProcessing="true">
     <match url="dev" />
     <conditions>
          <add input="{HTTP_HOST}" pattern="www.company.com" />
    </conditions>

    <action type="Rewrite" url="http://wwwtest.company.local:8081" />
    </rule>
  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 14, 2017 07:29 AM|Yuk Ding|LINK

    Hi KaneW,

    If you enable the Use URL Rewrite to inspect incoming requests, request will be handled by Application request routing module instead of URL rewrite module. That's why it get the error.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 15, 2017 01:03 AM|KaneW|LINK

    Hi Yuk;

    In this scenario, in what situation; I need to use ARR instead of URL Rewrite?  During my test, I setup a IIS server with "URL Rewrite" and another IIS server to host two web sites.  For the internal test, I can see the expected test result but I did not test from public internet yet.

    I hope my existing configuration on URL Rewrite to serve me the same test result when I try from public internet, is that right?

    I saw some guy using ARR  and URL Rewrite at the same time, what scenario can apply to the combination?

    thx!

  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 17, 2017 06:22 AM|Yuk Ding|LINK

    Hi KaneW,

    I think the URL rewrite to inspect incoming request will route all the request to the server farm. So if you need to use ARR server farm routing rule and normal routing rule, you could uncheck the  inspect incoming request. Then just route the rule based on the rewrite rule, it could still rewrite the request to server farm . Based on my understanding. you could use ARR and URL rewrite to build the reverse proxy. Server farm is always used to build the load balance.

    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 18, 2017 04:56 AM|KaneW|LINK

    Thanks!  I followed the example shown from the provided web page, it works.  Just curious, if not using ARR, just URL Rewrite, what is the difference and what will be the expected result.

    In general, using the ARR involve two NICs on proxy server, one for public internet, and one for internal.  The ARR will route the traffic from public to internal LAN.  If using URL Rewrite only, the IIS server with URL Rewrite and the destination web server must be on the same subnet.

    this is the only difference that I think of, is that correct?

  • Re: URL Rewrite redirect to the port 80 not port 8080 on Internal web server

    Jul 18, 2017 08:11 AM|Yuk Ding|LINK

    Hi KaneW,

    Yes. ARR works as a proxy when you were trying to build the reverse proxy. When you need to rewrite the URL to another domain or somewhere else like the NIC, it could report 404 if you don't enable the proxy in IIS manager->server level->application request routing cache->proxy.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.