求救,通过下面的配置,现在apache把所有网站元素都转发给了tomcat,
怎么让apache不转发静态内容(图片和css等)给tomcat呢?
ProxyRequests Off
ProxyPreserveHost on
NameVirtualHost *:80
VirtualHost default:80>
DocumentRoot /var/www/html
ServerName localhost:80
ProxyPass / http://localhost:9001/
#ProxyPass /_ui ajp://localhost:8009/_ui
ProxyPassReverse / http://localhost:9001/
#ProxyPassReverse /_ui ajp://localhost:8009/_ui
ProxyPass /_ui/ !
/VirtualHost>
NameVirtualHost *:443
VirtualHost *:443>
DocumentRoot /var/www/html
ServerName localhost:443
SSLProxyEngine On
ProxyPass / https://localhost:9002/
#ProxyPass /_ui ajp://localhost:8009/_ui
ProxyPassReverse / https://localhost:9002/
ProxyPass /_ui/ !
/VirtualHost>
配置贴上来之后把VirtualHost标签给自动屏蔽了,我擦。
你DocumentRoot 不就是设置了静态资源的地址了
常见有三种方法,JK,http_proxy,ajp_proxy ,
上面配置用的是http_proxy方法 加上下面的 信息 首先要
检查是否加载了mod_proxy.so和mod_proxy_http.so模块
httpd.conf最上面看一下
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_module modules/mod_proxy.so
ProxyPass / http://localhost:9001/<!-- tomcat 路径及端口 http://localhost 的所有请求代理到 http://localhost:8080/ -->
ProxyPass /images ! <!-- 图片请求不使用代理 -->
ProxyPass /css !<!-- css 加载请求 不使用代理-->
ProxyPass .js ! <!-- js 加载请求不使用代理 -->
根据上述配置加上负载均衡
ProxyPass / balancer://example/
BalancerMember http://localhost:9001/
BalancerMember http://localhost:9002/
<!-- 这bbs 把标签弄没了--><Proxy balancer://example/>
BalancerMember http://localhost:9001/
BalancerMember http://localhost:9002/
<!-- 还有一个-- >