[英]How do I fix “Port 80 requires elevated privileges” on Windows Azure with node.js?
I created the simple Node.js express tutorial and it runs locally. 我创建了简单的Node.js Express教程,它在本地运行。 I setup my Azure Web App to pull the repo from BitBucket, which it does, but I'm getting the following error in LogFiles/Application:
我将Azure Web App设置为从BitBucket中提取存储库,但确实如此,但是在LogFiles / Application中出现以下错误:
Port 80 requires elevated privileges
端口80需要提升的特权
Why would this be happening? 为什么会这样呢? Isn't node running at elevated privileges?
节点不是以提升的特权运行吗? If not, how do I configure it so it is?
如果没有,如何配置它?
UPDATE: IMPORTANT!!! 更新:重要!!!
This is never clearly explained in any documentation that I saw... 在我看到的任何文档中都从未明确解释过这一点...
Azure appears to be doing port forwarding for node.js applications. Azure似乎正在为node.js应用程序进行端口转发。 So when you hit your Azure URL on port 80/443 it gets forwarded to another port that your node.js application is running on.
因此,当您在端口80/443上单击Azure URL时,它将转发到运行node.js应用程序的另一个端口。 YOU DO NOT SET THAT PORT!!
您不设置那个端口! It is an environment variable managed by Azure so you simple listen at process.env.PORT.
它是由Azure管理的环境变量,因此您可以简单地侦听process.env.PORT。 Done, that's it.
完成,就是这样。
i assume you are using Azure App Service. 我假设您正在使用Azure App Service。 Even from end-user perspective, request is thru port 80, you will need to update your app to listen on port that get from environment variable, a port which load-balancer will actually distribute request to.
即使从最终用户的角度来看,请求也是通过端口80进行的,您将需要更新您的应用程序以侦听从环境变量获取的端口,负载平衡器实际上会将请求分发到该端口。
See below tutorial for more details. 有关更多详细信息,请参见下面的教程。
https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-develop-deploy-mac/ https://azure.microsoft.com/zh-CN/documentation/articles/web-sites-nodejs-develop-deploy-mac/
var http = require('http')
var port = process.env.PORT || 1337;
http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port);
I just fixed this. 我刚刚解决了这个问题。 In my case it was due to set PORT = 80 in env variables (Application Settings).
在我的情况下,这是由于在环境变量(应用程序设置)中设置了PORT = 80。 Once I removed PORT from there and let Azure automatically handle the port the error was gone.
一旦从那里删除PORT并让Azure自动处理该端口,错误就消失了。
Nginx (pronounced "engine x") is a web server. Nginx(发音为“ engine x”)是一个Web服务器。 It can act as a reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer and an HTTP cache.
它可以充当HTTP,HTTPS,SMTP,POP3和IMAP协议的反向代理服务器,以及负载平衡器和HTTP缓存。
It isn't good practice to run your application with root privileges or directly run your application on port 80. 使用root特权运行应用程序或直接在端口80上运行应用程序不是一个好习惯。
Run the app with sudo. 使用sudo运行该应用程序。 I would suggest you to check out this question.
我建议您检查一下这个问题。 https://stackoverflow.com/a/16573737/5583278
https://stackoverflow.com/a/16573737/5583278
Where the answer is to redirect the traffic from a nodejs port to port 80. Which will avoid having to run node as root. 答案是将流量从nodejs端口重定向到端口80。这将避免必须以root用户身份运行node。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.