经过大量的反复试验,我找到了解决问题的两种不同方法。
- 使用mod_rewrite和proxypass的一些更改:
<VirtualHost *:80> ProxyPreserveHost On ProxyPass /app http://localhost:8080/ui/ ProxyPassReverse /app http://localhost:8080/ui/ #since in java web app the context started with /ui the js src had /ui in the beginning #this resulted in 404 so I had to rewrite all request to /ui to forward to /app RewriteEngine on RewriteRule "^/ui(.+)" "/app$1" [R,L] ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>- 在webapp文件夹中创建到已部署应用程序的链接/快捷方式,并将shorcut命名为app在linux中,命令是(来自webapp文件夹中)
ln -s ui app
现在,apache配置为:
<VirtualHost *:80> ProxyPreserveHost On <Location /app> ProxyPass ajp://localhost:8019/app/ ProxyPassReverse ajp://localhost:8019/app/ SetOutputFilter proxy-html ProxyHTMLExtended On ProxyHTMLURLMap /app /app RequestHeader unset Accept-Encoding </Location> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>在第一种解决方案中,重写mod导致请求在重定向到正确的url之前返回304。这就是默认情况下的工作方式。
在第二种解决方案中,由于两个处理程序都是相同的(/ app),因此无需重新定向,并且URL正确映射。



