dimanche 6 septembre 2020

Nest JS Web Socket IIS Web.config setting

I want to know if anybody here can help. I have using Nest.js for my program and I have added some web socket code into my program for some new feature. However, when I deploy to the server and there are a problem to the IIS Setting.
Now I use URL rewrite for my http server. My HTTP server run on port 8200 in localhost. My web socket port is 8085. What I have tested is that I can call it in local using ws://localhost:8085/socket.io/?EIO=3&transport=websocket and also ws://192.168.X.X:8085/socket.io/?EIO=3&transport=websocket in internal network. However, I cannot call by ws://myurl.com/socket.io/?EIO=3&transport=websocket. The URL is binding with a IIS server. Below is my IIS server web.config. Is it because we socket cannot called by url? or is my web.config have something wrong? Can anybody help me?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WebSocketsReverseProxy" enabled="true" stopProcessing="true">
          <match url="ws://(.*)"/>
          <action type="Rewrite" url="ws://localhost:8085/{R:1}"/>
        </rule>
        <rule name="HttpsReverseProxy" stopProcessing="true">
          <match url="(.*)"/>
          <conditions>
            <add input="{CACHE_URL}" pattern="^(https?)://"/>
          </conditions>
          <action type="Rewrite" url="http://localhost:8200/{R:1}"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>



Aucun commentaire:

Enregistrer un commentaire