如何使apache,node.js,beego和https很好地一起工作?

我有一个服务器,我想要提供两个不同的网站:

  • a.example.com应该定向到在8081/8443上监听的node.js
  • b.example.com应该被引导到在8081/8444上的beego监听

我有Apache HTTPD在80听,并使用以下指令

<VirtualHost *:80> ServerName a.example.com ProxyPreserveHost On <Proxy *> Order allow,deny Allow from all </Proxy> ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ </VirtualHost> <VirtualHost *:80> ServerName b.example.com ProxyPreserveHost On <Proxy *> Order allow,deny Allow from all </Proxy> ProxyPass / http://localhost:8081/ ProxyPassReverse / http://localhost:8081/ </VirtualHost> 

通过http使用这些工作就像你想象的那样。 现在我的问题是与https保护网站。 当我有任何一个站点在Apache httpdclosures的情况下在端口80上监听时,https是有效的。 然而,让他们与Apache玩好并不容易。

所以我尝试添加

 <VirtualHost *:443> ServerName a.example.com ProxyPreserveHost On SSLProxyEngine on SSLEngine on SSLCertificateFile /path/to/a/sslcert/server.crt SSLCertificateKeyFile /path/to/a/sslcert/server.key <Proxy *> Order allow,deny Allow from all </Proxy> ProxyPass / https://localhost:8443/ ProxyPassReverse / https://localhost:8443/ </VirtualHost> 

和b.example.com等效,但尝试访问https:// {a | b} .example.com

 Proxy Error The proxy server could not handle the request GET / Reason: Error during SSL Handshake with remote server 

我认为这与beego和node.js都使用自己的httpd来build立https,所以我再试一次…但没有4个SSL相关的线。
这次的结果是

 Error code: ERR_SSL_PROTOCOL_ERROR (chrome) Error code: ssl_error_rx_record_too_long (firefox) 

我不知道下一步该怎么做,谷歌变成空的,所以我希望有一些帮助从你们/女孩得到?

我需要beego和node.js网站都能够设置他们自己的https设置,所以他们可以在有和没有Apache前面工作。 这是可行的吗?

 # httpd -S VirtualHost configuration: *:443 is a NameVirtualHost default server a.example.com (/etc/httpd/conf/extra/httpd- vhosts.conf:30) port 443 namevhost a.example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:30) port 443 namevhost b.example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:62) *:80 is a NameVirtualHost default server www.example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:24) port 80 namevhost www.pontusfa.lk (/etc/httpd/conf/extra/httpd-vhosts.conf:24) alias example.com port 80 namevhost a.example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:48) port 80 namevhost b.example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:80) ServerRoot: "/etc/httpd" Main DocumentRoot: "/srv/http" Main ErrorLog: "/var/log/httpd/error_log" Mutex ssl-stapling: using_defaults Mutex proxy: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/run/httpd/" mechanism=default Mutex mpm-accept: using_defaults Mutex proxy-balancer-shm: using_defaults PidFile: "/run/httpd/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="http" id=33 Group: name="http" id=33 

我没有看到用HTTPS连接到节点/ beego的重点。

你试一试:

客户—> HTTPS-Apache —> HTTP-node

记住节点是单线程的,所以你不应该在密集的CPU上使用它(和它是SSL),否则请求将排队。