侦听其他端口Microsoft Azure Node.js [英] Listen additional port Microsoft Azure Nodejs

查看:84
本文介绍了侦听其他端口Microsoft Azure Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在端口process.env.PORT(1337)(Microsoft Azure的默认端口)上运行nodejs应用程序(Azure Web App). 另外,我需要监听websocket的其他端口.在我的本地计算机上,我使用的是8000,但似乎在Azure上已关闭.

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 local I'm using 8000, but seems, that it's closed on Azure.

有没有其他我可以收听的端口,实际上有可能吗?

Are there any additional ports, that I can listen and is it actually possible at all?

推荐答案

如果要部署到Azure Web App,则只有端口80和443是面向公众的.这会映射到您的应用程序要监听的特定端口,可通过process.env.PORT检索.而且,如果您同时在Azure和本地中运行,则可以基于对问题中端口1337的引用,轻松地管理监听的端口,诸如此类:

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;

如果您需要侦听多个端口或不同于80/443的端口,则需要部署到VM或Cloud Service(Web/工作者角色).或部署多个Web应用.

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.

这篇关于侦听其他端口Microsoft Azure Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆