Node.js 使用SSL运行的NodeJ,Apache2代理不工作

Node.js 使用SSL运行的NodeJ,Apache2代理不工作,node.js,apache,ssl,apache2,lets-encrypt,Node.js,Apache,Ssl,Apache2,Lets Encrypt,我一直在尝试运行一个NodeJS应用程序,该应用程序可以使用:x(端口号)进行访问,但它运行在 subdomain.domain.com:x 当NodeJS应用程序使用没有SSL配置的http服务器时,Apache配置工作正常,new.domain.com被代理到subdomain.domain.com:x即可 但是,当NodeJS应用程序是带有https的服务器时,Apache会生成502个坏网关错误。下面是我一直在使用的配置。我什么都试过了,但就是不行 请注意,我已将原始端口号和子域替换为

我一直在尝试运行一个NodeJS应用程序,该应用程序可以使用:x(端口号)进行访问,但它运行在

subdomain.domain.com:x
当NodeJS应用程序使用没有SSL配置的
http
服务器时,Apache配置工作正常,
new.domain.com
被代理到
subdomain.domain.com:x
即可

但是,当NodeJS应用程序是带有
https
的服务器时,Apache会生成502个坏网关错误。下面是我一直在使用的配置。我什么都试过了,但就是不行

请注意,我已将原始端口号和子域替换为随机名称,以隐藏真实的域名


<VirtualHost *:443>
        DocumentRoot /var/www/html


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        ServerName new.domain.com 

        SSLProxyEngine On
        SSLEngine On
        SSLCertificateFile <Path/To/SSLCertificate>/fullchain.pem
        SSLCertificateKeyFile <Path/To/SSLCertificateKeyFile>/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

        ProxyRequests off
        ProxyPreserveHost On
        ProxyPass / https://subdomain.domain.com:x/
</VirtualHost>
<VirtualHost *:80>
   CustomLog ${APACHE_LOG_DIR}/subdomain.domain.com-access.log combined
   ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.com-error.log

   ServerName new.domain.com   
   Redirect "/" "https://new.domain.com/"

</VirtualHost>
const https = require("https"),
  fs = require("fs");

const options = {
  key: fs.readFileSync("/srv/www/keys/my-site-key.pem"),
  cert: fs.readFileSync("/srv/www/keys/chain.pem")
};

const app = express();

app.use((req, res) => {
  res.writeHead(200);
  res.end("hello world\n");
});

app.listen(8000);

https.createServer(options, app).listen(8080);