如何使用具有不同端口的单个 ssl 证书运行节点 js 和 apache?

Posted

技术标签:

【中文标题】如何使用具有不同端口的单个 ssl 证书运行节点 js 和 apache?【英文标题】:How can I run node js and apache with single ssl certificate with different port? 【发布时间】:2018-05-29 09:31:04 【问题描述】:

我在端口号 3000 上使用 nodejs,并且我的网站是经过 ssl 认证的。运行 node server.js 后出现以下错误:

GET https://--.---.-.---:3000/socket.io/?EIO=3&transport=polling&t=1513323461271-0net::ERR_CONNECTION_REFUSED。

那么,我的网站托管在 Amazon Server 上。

【问题讨论】:

【参考方案1】:

希望您已经在 Apache

中配置了 SSL

节点(快递)

const express = require('express');
const app = express();
var cors = require('cors')
app.use(cors());
var server = require('http').createServer(app);

在服务器中打开 httpd.conf 并根据需要添加 ProxyPass

ProxyPass /api/ http://localhost:3000/

不要忘记重新启动 HTTP 服务

http://www.example.com/mypageapache http:好的!

https://www.example.com/mypageapache https:好的!

http://www.example.com/api/节点http:好的!

https://www.example.com/api/ 节点 https:它可以工作!!!

【讨论】:

以上是关于如何使用具有不同端口的单个 ssl 证书运行节点 js 和 apache?的主要内容,如果未能解决你的问题,请参考以下文章