栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Apache proxypass无法解析图像和CSS等资源的url

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Apache proxypass无法解析图像和CSS等资源的url

经过大量的反复试验,我找到了解决问题的两种不同方法。

  1. 使用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>
  1. 在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正确映射。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/426420.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号