之前甲方一直将文件服务器与应用服务器放在同一apche下,现在将文件服务器与应用服务器分开了,一开始以为图片的上传以及文件的上传代码不能通过apche配置进行请求转发,需要后台进行请求转发。后来才知道可以在apche中的httpd.conf文件中进行请求转发,甚至进行服务器的负载均衡配置。
①
找到该文件
②NameVirtualHost *:80
ProxyPreserveHost On
<VirtualHost *:80>
ProxyRequests Off
ProxyPass /server-status !
ProxyPass /socketserver http://127.0.0.1:7888
ProxyPass /rest/file http://10.10.2.60:11080/rest/file
ProxyPassReverse /rest/file http://10.10.2.60:11080/rest/file
ProxyPass /rest/base/file http://10.10.2.60:11080/rest/base/file
ProxyPassReverse /rest/base/file http://10.10.2.60:11080/rest/base/file
ProxyPass /uploaded http://10.10.2.60:11080/uploaded
ProxyPassReverse /uploaded http://10.10.2.60:11080/uploaded
ProxyPass /rest/bo/Knowledge http://10.10.2.60:11080/rest/bo/Knowledge
ProxyPassReverse /rest/bo/Knowledge http://10.10.2.60:11080/rest/bo/Knowledge
ProxyPass /rest/base/file2 http://10.10.2.60:11080/rest/base/file2
ProxyPassReverse /rest/base/file2 http://10.10.2.60:11080/rest/base/file2
ProxyPass /rest/bo/CompPic http://10.10.2.60:11080/rest/bo/CompPic
ProxyPassReverse /rest/bo/CompPic http://10.10.2.60:11080/rest/bo/CompPic
ProxyPass / balancer://tomcatcluster/ lbmethod=byrequests stickysession=JSESSIONID nofailover=Off timeout=5 maxattempts=3
ProxyPassReverse / balancer://tomcatcluster/
<Proxy balancer://tomcatcluster>
BalancerMember http://10.10.2.54:6080 route=tomcat2 loadfactor=1
BalancerMember http://10.10.2.54:7080 route=tomcat2 loadfactor=1
BalancerMember http://10.10.2.54:8080 route=tomcat2 loadfactor=1
BalancerMember http://10.10.2.54:9080 route=tomcat2 loadfactor=1
</Proxy>
</VirtualHost>
在该文件中进行转发以及负载均衡配置