We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Redirection for API linksRSS

2 replies

Last post Mar 18, 2020 08:06 AM by Jalpa Panchal

  • Redirection for API links

    Mar 17, 2020 06:55 AM|TwekanFreak|LINK

    Hey everyone. I have an Angular application that is required to make API requests on 

    https://mydomain.com:8080/mayapp

    So my problem is that I need to redirect these incoming requests to this URL but the API does not have SSL for https requests. I want to use the "mydomain.com" bound to SSL certificate from IIS to redirect my requests over https. Is that possible or am I way off here? 

    Thanks for your time reading this.

  • Re: Redirection for API links

    Mar 17, 2020 06:45 PM|lextm|LINK

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

    Lex Li
    Want to have a chat on the issues you meet? Book an appointment at https://buy.stripe.com/cN24ia0yi7sAdIA7sv
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Redirection for API links

    Mar 18, 2020 08:06 AM|Jalpa Panchal|LINK

    Hi,

    You could use the IIS arr reverse proxy rule to implement your requirement:

    For that, you need to install the iis URL rewrite module and the Application Request Routing from the below link.

    https://www.iis.net/downloads/microsoft/application-request-routing

    https://www.iis.net/downloads/microsoft/url-rewrite

     <rewrite>
                <rules>
                                              
                    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                        <match url="(.*)" />
                        <action type="Rewrite" url="http://www.sample1.com/{R:1}" />
                    </rule>
                </rules>
                <outboundRules>
                    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^http(s)?://www.sample1.com/(.*)" />
                        <action type="Rewrite" value="http{R:1}://www.sample2.com/{R:2}" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
            </rewrite>

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.