![为什么该服务器的负载平衡不起作用?](https://linux22.com/image/763477/%E4%B8%BA%E4%BB%80%E4%B9%88%E8%AF%A5%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E8%B4%9F%E8%BD%BD%E5%B9%B3%E8%A1%A1%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%9F.png)
我正在尝试使用 Apache 和反向代理模式设置负载平衡。但我遇到了一些问题。尝试配置时,响应了 HTTP 403 错误。这是我正在尝试的配置:
Listen 9104
<Location "/balancer-manager">
SetHandler balancer-manager
Allow from all
</Location>
<VirtualHost *:9104>
DocumentRoot /var/www/html/
ServerName appempmam.desabpd.popular.local
<Proxy balancer://mycluster>
BalancerMember "http://10.15.5.152:9100/" route=1
#BalancerMember "http://0.0.0.0:8081/" route=2
ProxySet lbmethod=byrequests
</Proxy>
ProxyPreserveHost On
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
ErrorLog /var/log/httpd/proxy-error.log
CustomLog /var/log/httpd/proxy-access.log combined
</VirtualHost>
如果我用实际的后端服务器而不是集群名称替换proxypass
和proxypassreverse
条目,那么它就可以正常工作,请求也会得到正确的响应,但是当使用负载平衡时,它就不起作用了。我在日志中搜索了任何类型的错误,但什么也没找到。我需要平衡才能正常工作,因为不久的将来会添加另一台服务器。我这里漏掉了什么吗?
我正在使用 Apache 2.4 和 Red Hat 8.1。
顺便说一句,这是主配置文件中的目录权限条目:
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
# Require all granted
</Directory>