我该如何使用单个SSL证书在不同端口下运行Node.js和Apache?

3

我正在使用端口号3000上的nodejs,并且我的网站已经获得了ssl认证。在运行node server.js之后,我收到了以下错误:

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

那么,我该如何在不同的端口上使用单个ssl证书运行node js和apache?而我的网站托管在亚马逊服务器上。

1个回答

4
我希望你已经在 Apache 中配置了 SSL。
Node(Express)中:
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/mypage Apache HTTP:正常! https://www.example.com/mypage Apache HTTPS:正常! http://www.example.com/api/ Node HTTP:正常! https://www.example.com/api/ Node HTTPS:已经运行!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接