node.js - 与服务器建立多个连接有什么意义?

标签 node.js server hapi.js

The Server object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080).

与服务器建立多个连接有什么意义?内存?速度?安全吗?

最佳答案

最明显的用例是允许将 TLS 和非 TLS 请求路由到同一服务器。您与同一服务器建立了 2 个连接,一个具有 TLS 配置,另一个没有。

var Hapi = require('hapi');

var server = new Hapi.Server();

// Receives TLS requests

server.connection({
    port: 443,
    tls: {
        key: ...,
        cert: ...
    }
});

// Requests HTTP requests

server.connection({ port: 80 });

...

关于node.js - 与服务器建立多个连接有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31318481/

相关文章:

node.js - 如何使用 Braintree 从 webhook 获取客户 ID?

javascript - 如何远程自动更新 node.js 应用程序

sockets - ESP32 MicroPython SSL WebSocket 服务器失败

node.js - 作为 MQTT 客户端的服务器可以处理多少条消息

javascript - 如何在 Hapi JS 中验证提供静态文件的 URL

javascript - Hapi js重定向到带有附加请求数据的另一条路由

javascript - 为每个 Hapi 路由添加状态代码

node.js - 获取 SignatureDoesNotMatch : null error while uploading images to DigitalOcean Spaces using multers3 node. js

javascript - 在 node.js 中使用 Firebase 3.0 进行身份验证

html - CSS 不会在服务器上加载图像