vendredi 14 mai 2021

IIS with vue.js + api | URL Rewrite rule to forward to api

I host vue.js3 and asp.net core on the same Server. My admins only allow to get traffic through 443/https. Therefore I'm trying to get a ReverseProxy(?) to run.

All traffic to https://pim.test.de should go to the site of this web.config (vue.js) with the second rule (for vue-router history mode). But traffic that goes to a link containing /api/ like https://pim.test.de/api/service/getinfoall should be forwarded to the port 44310, where the ASP.net core application is reachable. So internally it should reroute the request to https://pim.test.de:44310/api/service/getinfoall

What am I doing wrong? Even without the second rule, which kills vue-router, it isn't forwarding direct requests to the api/asp.net.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>

        <rule name="Handle /api by redirecting to port 44310 (masterservice)">
          <match url="/api/(.*)" />
          <action type="Rewrite" url="https://pim.test.de:44310/api/{R:1}" logRewrittenUrl="true" />
        </rule>

        <rule name="Handle History Mode and custom 404/500" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>

      </rules>
    </rewrite>
  </system.webServer>
</configuration>



Aucun commentaire:

Enregistrer un commentaire