Apache的反向代理404图像错误

我有一些与我的Apache反向代理错误。 目前我正在做4个网站的反向代理。

  • 1.1.1.1/a
  • 1.1.1.2/b
  • 1.1.1.3/c
  • 1.1.1.4/d

反向代理到a和b网站时,我没有问题。 形象是好的,没有问题。

但是,当涉及到C和D的网站。 图像没有得到加载。在我的access_log,这里是日志。

- - [08/May/2014:10:40:36 +0800] "GET /whatshot_v3/images/promo/img_samplePromo.jpg HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/menu/faq_butt_03.png HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_planprice.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_services.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_account.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_store.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_rewards.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_idd.gif HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/img_customerService.png HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_fb.png HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_tw.png HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_rss.png HTTP/1.1" 404 1245 - - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_share.png HTTP/1.1" 404 1245 

从Apache反向代理服务器本身访问没有问题。 从外部访问时,会出现问题。

我已经尝试直接在另一台机器上inputurl,并加载图像。

 1.1.1.1 - - [08/May/2014:10:19:00 +0800] "GET **/d/images_v3/footer/icon_share.png** HTTP/1.1" 200 869 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36 1.1.1.1 - - [08/May/2014:10:18:24 +0800] "GET **/images_v3/footer/icon_share.png HTTP/1.1" 404 1245** "htt://1.2.3.4/digi/landing.do" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36" 

正如你可以看到第一个链接正在工作。 第二个是没有的。

当我正常请求网页的时候,会请求第二个链接,导致404错误,找不到path。

如果我直接键入第一个链接,图像被发现。

我注意到c和d网站在input链接时被redirect。这是问题的原因。

 1.1.1.3/c --> 1.1.1.3/c/index_other.html 1.1.1.4/d --> 1.1.1.4/d/landing.do 

这是我的Apache反向代理configuration

 <VirtualHost *:80> #ServerAdmin [email protected] #DocumentRoot /www/docs/dummy-host.example.com #ServerName dummy-host.example.com ErrorLog logs/arp_error_log CustomLog logs/arp_access_log common ProxyRequests Off <Location /a> ProxyPass http://1.1.1.1/a ProxyPassReverse http://1.1.1.1/a </Location> <Location /b> ProxyPass http://1.1.1.2/b ProxyPassReverse http://1.1.1.2/b </Location> <Location /c> ProxyPass http://1.1.1.3/index_other.html ProxyPassReverse http://1.1.1.3/index_other.html </Location> <Location /d> ProxyPass http://1.1.1.4:8080 ProxyPassReverse http://1.1.1.4:8080 </Location> </VirtualHost> 

那么,我该如何解决呢? 我一直在研究mod_rewrite和mod_proxy_html,但没有解决问题的运气。

您可以为图像使用单独的位置容器。

我不是testing这个,但这应该是或多或less的。

对于/ c:

  <Location /c/images_v3> ProxyPass http://1.1.1.3/images_v3 ProxyPassReverse http://1.1.1.3/images_v3 </Location> <Location /c> ProxyPass http://1.1.1.3/index_other.html ProxyPassReverse http://1.1.1.3/index_other.html </Location> 

对于/ d我不是很确定什么是偶然的,也许在1.1.1.4:8080有一个redirect到/landing.do? 在这种情况下,以下将不会有帮助:

  <Location /d/images_v3> ProxyPass http://1.1.1.4:8080/images_v3 ProxyPassReverse http://1.1.1.4:8080/images_v3 </Location> <Location /d> ProxyPass http://1.1.1.4:8080 ProxyPassReverse http://1.1.1.4:8080 </Location>