问题描述
我已经设置并运行了 2 个环境,我正在尝试创建与已创建的环境类似的第三个环境。但是对于后端,我认为我收到了与代理相关的错误。
这是错误日志:
[proxy:error] [pid 2814] (111)Connection refused: AH00957: HTTP: attempt to connect to 178.62.203.15:8990 (testing.api.requests.tarbeeta.com) Failed
[proxy:error] [pid 2814] AH00959: ap_proxy_connect_backend disabling worker for (testing.api.requests.tarbeeta.com) for 60s
[proxy_http:error] [pid 2814] [client 41.44.42.14:64296] AH01114: HTTP: Failed to make connection to backend: testing.api.requests.tarbeeta.com,referer: http://testing.api.r$
这是我的虚拟主机的设置
<VirtualHost *:80>
# 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@tarbeeta.com
ServerName testing.api.requests.tarbeeta.com
ServerAlias testing.api.requests.tarbeeta.com
DocumentRoot /var/www/testing.requests.tarbeeta.com/server/public_html
ProxyPass / http://testing.api.requests.tarbeeta.com:8990/
ProxyPassReverse / http://testing.api.requests.tarbeeta.com:8990/
# 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
RewriteEngine on
RewriteCond %{SERVER_NAME} =testing.api.requests.tarbeeta.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# vim: Syntax=apache ts=4 sw=4 sts=4 sr noet
这与其他两个 vhost 的配置相同,但它们使用不同的端口。我不知道我是否必须在其他地方配置端口才能进行这项工作。
谢谢。
解决方法
错误显示端口 8990
上的连接尝试,但您的 Apache 配置正在侦听端口 80
。您将需要调整 Apache 以查看与您的虚拟主机以及 /etc/apache2/ports.conf
中的正确端口。从那里开始,如果您在 Ubuntu 上使用 ufw
和 Droplet,您需要更新防火墙以允许端口 8990
上的流量通过。
对于您的虚拟主机
<VirtualHost *:80>
变成:
<VirtualHost *:8990>
对于ports.conf
# If you just change the port or add more ports here,you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
变成:
# If you just change the port or add more ports here,you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
Listen 8990
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
注意:如果流量永远不会通过端口 80
发送到服务器,您可以从文件中删除该行。
更新防火墙
sudo ufw allow 8990
终于……
重启 Apache:
sudo service apache2 restart
这会给你你所需要的。