Reputation: 10911
I created the simple Node.js express tutorial and it runs locally. 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:
Port 80 requires elevated privileges
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. 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. YOU DO NOT SET THAT PORT!! It is an environment variable managed by Azure so you simple listen at process.env.PORT. Done, that's it.
Upvotes: 6
Views: 21368
Reputation: 904
I just fixed this. In my case it was due to set PORT = 80 in env variables (Application Settings). Once I removed PORT from there and let Azure automatically handle the port the error was gone.
Upvotes: 2
Reputation: 1615
Use Nginx,
Nginx (pronounced "engine x") is a web server. 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.
It isn't good practice to run your application with root privileges or directly run your application on port 80.
Upvotes: 1
Reputation: 3777
i assume you are using 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.
See below tutorial for more details.
https://azure.microsoft.com/en-us/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);
Upvotes: 3
Reputation: 448
Run the app with sudo. I would suggest you to check out this question. 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.
Upvotes: 0