尝试连接到新环境时出现 503 错误

Posted

技术标签:

【中文标题】尝试连接到新环境时出现 503 错误【英文标题】:I'm getting 503 error when I try to connect to my new environment 【发布时间】:2021-07-30 14:14:26 【问题描述】:

我已经有 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

这与其他两个虚拟主机的配置相同,但它们使用不同的端口。我不知道我是否必须在其他地方配置端口才能完成这项工作。

谢谢。

【问题讨论】:

【参考方案1】:

错误显示在端口 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

这会给你你所需要的。

【讨论】:

以上是关于尝试连接到新环境时出现 503 错误的主要内容,如果未能解决你的问题,请参考以下文章

设置 Github Jenkins 插件时出现“无法连接到存储库”错误

当我尝试连接到 mongodb 时出现这些错误

当我尝试连接到 mongodb 时出现这些错误

尝试使用 SQLWorkbench 连接到 Amazon Redshift 时出现操作超时错误

尝试使用 mysqli 连接到数据库时出现 Codeigniter 错误

连接到 cloudera impala 环境时出现 Kerberos 错误