简体   繁体   English

带有https的node.js集群

[英]node.js cluster with https

I'm using the cluster npm for my node app. 我正在为节点应用程序使用集群npm

var cluster = require('cluster');
var app = express.createServer({
    key: fs.readFileSync('privatekey.pem'),
    cert: fs.readFileSync('certificate.pem')
});

cluster(app)
 .use(cluster.logger('logs'))
 .use(cluster.stats())
 .use(cluster.pidfiles('pids'))
 .use(cluster.cli())
 .listen(443);

But I got the Permission denied when I use port 443. It's working fine if I use another port . 但是当我使用端口443时,我的权限被拒绝了。如果使用其他端口,它可以正常工作。 Obviously 443 is dedicated to https, so how can I use it for my app ? 显然443是专用于https的,那么如何在我的应用程序中使用它呢?

By default node can't access lower ports (unless you're root ). 默认情况下,节点无法访问较低的端口(除非您是root )。 Don't be afraid though since any port will do. 不过不要害怕,因为任何端口都可以。

The one usually used for development purposes is 8443 : 通常用于开发目的的是8443

 .listen(8443);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM