502 Ubuntu 14.04上的Apache2反向代理出错502

时间:2016-04-28 23:27:46

标签: node.js apache2 ubuntu-14.04 reverse-proxy

我试图设置一个反向代理,Apache2服务器在端口443接受请求(启用https)。我的想法是让Apache2服务器接受请求并将其转发到我的节点服务器,该服务器正在侦听端口4443.我已经查看了几个示例配置来设置虚拟主机,并在切换了几个选项之后我仍然得到502错误。两台服务器都托管在运行Ubuntu 14.04的DigitalOcean Droplet上。

我可以直接在Chrome中点击端口4443并为Node应用提供服务。当我加载没有端口号的站点时,它加载端口443(如预期的那样),我收到此错误:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.

Reason: Error reading from remote server

Apache/2.4.7 (Ubuntu) Server at [domain.com] Port 443

在控制台中,它说:

Failed to load resource: the server responded with a status of 502 (Proxy Error)

以下是我所关注的资源:

https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

https://support.mayfirst.org/wiki/how-to/servers/configure-nodejs-with-apache

这是我的配置文件。实际的IP和域将替换为[IP]和[domain.com]。

<IfModule mod_ssl.c>
<VirtualHost *:443>
  # The ServerName directive sets the request scheme, hostname and port that
  # the server uses to identify itself. This is used when creating
  # redirection URLs. In the context of virtual hosts, the ServerName
  # specifies what hostname must appear in the request's Host: header to
  # match this virtual host. For the default virtual host (this file) this
  # value is not decisive as it is used as a last resort host regardless.
  # However, you must set it for any further virtual host explicitly.
  #ServerName www.example.com

  ServerAdmin admin@[domain.com]
  ServerName [domain.com]
  ServerAlias www.[domain.com]
  DocumentRoot /var/www/[domain.com]/public_html

  #SSL Configuration
  SSLEngine On
  SSLProxyEngine On
  SSLCertificateFile /etc/letsencrypt/live/[domain.com]/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/[domain.com]/privkey.pem
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateChainFile /etc/letsencrypt/live/[domain.com]/chain.pem 

  ProxyPreserveHost On
  ProxyRequests off 
  ProxyPass / http://[IP]:4443/ retry=1 acquire=3000 timeout=3000 Keepalive=On
  ProxyPassReverse / http://[IP]:4443/

  # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
  # error, crit, alert, emerg.
  # It is also possible to configure the loglevel for particular
  # modules, e.g.
  #LogLevel info ssl:warn

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

  # For most configuration files from conf-available/, which are
  # enabled or disabled at a global level, it is possible to
  # include a line for only one particular virtual host. For example the
  # following line enables the CGI configuration for this host only
  # after it has been globally disabled with "a2disconf".
  #Include conf-available/serve-cgi-bin.conf

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>

如何编辑配置文件以解决此502错误?

0 个答案:

没有答案