【问题标题】:node http proxy port number to accept SSL traffic接受 SSL 流量的节点 http 代理端口号
【发布时间】:2016-06-22 06:37:59
【问题描述】:

以下示例取自node-http-proxy的github页面

HTTPS -> HTTP

//
// Create the HTTPS proxy server in front of a HTTP server
//
httpProxy.createServer({
  target: {
    host: 'localhost',
    port: 9009
  },
  ssl: {
    key: fs.readFileSync('valid-ssl-key.pem', 'utf8'),
    cert: fs.readFileSync('valid-ssl-cert.pem', 'utf8')
  }
}).listen(8009);


问题:为什么 httpProxy 不侦听端口 443 以获取安全 SSL 流量?

【问题讨论】:

    标签: node.js ssl proxy node-http-proxy


    【解决方案1】:

    SSL 的默认端口是 443,但与常规的 HTTP 协议一样,它也有默认的 80 端口,它可以绑定到自定义端口并通过在 url (https://localhost:8009) 中指定端口来访问。基于this answer

    【讨论】:

    • 我明白了,但这会导致不必要的复杂网址,例如example.com:8009/foobar.html
    • 是的,在大多数情况下,使用 443 端口就足够了,但有时,例如,当您在一台服务器上托管多个站点时,您应该处理端口冲突,因此,为 SSL 使用自定义端口.
    猜你喜欢
    • 2012-04-22
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 2014-04-09
    • 1970-01-01
    相关资源
    最近更新 更多