Construction of experimental Environment:
Web server director:192.168.11.131 (host-only) 192.168.1.114 (bridge) installs Apache
App Server1 rs1:192.168.11.132 (host-only) installs Tomcat
App Server2 rs2:192.168.11.129 (host-only) installs Tomcat
One, using Apache Mod_proxy and Tomcat connection
1. Check if Apache has loaded the required modules
httpd-d Dump_modules|grep Proxy
2. Comment out the DocumentRoot "/var/www/html" in httpd.conf
3. At/etc/httpd/conf.d,vim httpd-proxy.conf
<virtualhost *:>/http://192.168.11.132:8080/rs1/proxypassreverse/ http://192.168.1.114:8080:rs1/<proxy *># Require all granted</Proxy> <location/># Require all granted</Location></VirtualHost>
Annotations:
Proxyvia off
#用于控制httpd首部是否使用via, default off
Proxyrequests off
#是否开启Apache的正向代理功能, enabling this key must enable the Mod_proxy_http module, and if Proxypass is set, it must be set to OFF
proxypass/http://192.168.11.132:8080/rs1/
#path (/) is a virtual path on the current server, and the URL (http://192.168.11.132:8080) is a URL path to the back-end server.
If path ends with a/end, then the URL must also end with/, and httpd2.1 later supports the backend-to-server connection pooling feature, which can be defined using Key=value. Common key
Min: Connection pool Minimum amount of space to initialize
Max: Maximum capacity of the connection pool
Loadefactor: For load balancing, define the weight of the backend server
Retry: How long it takes to get an error response to the backend to wait for the second to retry, in seconds
Proxypassreverse/http://192.168.1.114:8080/rs1
#在反向代理中必须使用此指令避免重定向报文绕过代理服务器
<proxy *>
#如果小于2.4, remove require all granted this line
Require all granted
</Proxy>
<location/>
#如果小于2.4, remove require all granted this line
Require all granted
</Location>
4. Verify Access http://192.168.1.114
Tomcat implements reverse proxy