The previous chapter describes how to use the reverse proxy function of apache2.2.4 to achieve load balancing and run properly. However, a problem was found recently, that is, the end of the URL address is the Directory, which causes Apache to automatically add a slash.
If you do not use the proxy function, you can configure directoryindex index.shtml for the Apache directory, and then add a slash to the Directory Access automatically. For example, when accessing the http://www.test.com/dir, if DIR is the directory in the actual file system, Apache will automatically add a slash to become the access http://www.test.com/dir/, that is, access the default index file index.shtml under the Dir directory.
After the proxy is configured, Apache cannot automatically afford the slash. Even if rewriterule ^/([^/. +] | [^/]) $/$1/[R] is manually added, it is really depressing.
After Google and constantly changing the configuration, we found a configuration: proxypreservehost on. By default, the value of this parameter is off. If you have not carefully studied the underlying meaning of this parameter, it means that the reverse proxy forwards requests to all hosts (after redirection, the proxy request changes, so that the proxy cannot identify whether it is from the same host reserver ?).
After this configuration is added at the bottom of the proxypass rule, the problem is solved. The screenshot configuration is as follows:
<Proxy balancer: // proxy>
Balancermember http: // 192.168.10.11: 8083 loadfactor = 1
Balancermember http: // 192.168.10.12 loadfactor = 1
</Proxy>
Namevirtualhost *: 80
<Virtualhost *: 80>
Serveradmin webmaster@12582.com
Servername www.12582.com
DocumentRoot/WWW
Directoryindex index.shtml
<Directory/WWW>
AllowOverride all
Addtype text/html. shtml
Addtype application/X-Rar. rar
Addhandler server-parsed. shtml
Options + IncludesNOEXEC
Ssierrormsg "<! -- Error -->"
Deny from 222.128.6.82
</Directory>
Rewriteengine on
Proxypass/tlimages /!
Proxypass/imagelist /!
Proxypass/xiazai /!
Proxypass/AD /!
Proxypass/balancer: // proxy/
Proxypassreverse/balancer: // proxy/
Proxypreservehost on
</Virtualhost>