Listen additional port Microsoft Azure Nodejs

前端 未结 1 1850
长情又很酷
长情又很酷 2020-11-29 12:57

I\'m running nodejs application (Azure Web App) on port process.env.PORT (1337), default port on Microsoft Azure. Also I need to listen additional port for websocket. On my

相关标签:
1条回答
  • 2020-11-29 14:03

    If you're deploying to an Azure Web App, only ports 80 and 443 are public-facing. This maps to a specific port for your app to listen to, retrievable via process.env.PORT. And if you're running both in Azure and locally, you can easily manage which port you listen to, with something like this, based on your reference to port 1337 in your question:

    var port = process.env.port || 1337;
    

    If you needed to listen in on multiple ports, or ones different from 80/443, you'd need to deploy to a VM or a Cloud Service (web/worker role). Or deploy multiple web apps.

    0 讨论(0)
提交回复
热议问题