Proxypreservehost configuration of Apache reverse proxy

Source: Internet
Author: User
Tags rar
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.