NodeJS-代理错误-从远程服务器读取错误

时间:2020-06-08 13:13:45

标签: node.js express certificate apache2 cloudflare

我在获取证书时遇到问题:

我的节点script.js

var fs = require('fs');
var http = require('http');
var https = require('https');
var express = require('express');
var app = express();

var server = https.createServer({
    key: fs.readFileSync(`${__dirname}/certificate.key`),
    cert: fs.readFileSync(`${__dirname}/certificate.crt`)
}, app);

server.listen(2053, function() {
    console.log('Listen ok');
});

app.get('/', function(req, res) {
    res.status(200).json({
        "success": true
    });
});

我的apache conf

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://localhost:2053/
    ProxyPassReverse / http://localhost:2053/
</VirtualHost>

<VirtualHost *:443>
    ProxyRequests Off
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/certificate.crt
    SSLCertificateKeyFile /etc/apache2/ssl/certificate.key
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPreserveHost On
    ProxyPass / http://localhost:2053/
    ProxyPassReverse / http://localhost:2053/
</VirtualHost>

输入域名时,我会遇到这样的错误(Attachment 1)

502 Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request

Reason: Error reading from remote server

当我在链接中添加:2053(端口)时,我得到的结果是(Attachment 2),但我仍然没有“安全连接”

我希望它能在没有端口的域上正常工作,就像使用端口名称(:2053)一样,并用于安全连接

0 个答案:

没有答案