Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have some error with my apache reverse proxy. Currently I am doing reverse proxy to 4 websites.

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

I am having no problem when reverse proxy to a and b website. Image are good and no problem.

However, when comes to c and d website. Image are not getting loaded.In my access_log , here are the logs.

- - [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

Accessing from the apache reverse proxy server itself have no problem. When accessing from outside, the problem occur.

I have try directly typing the url in another machine and the image are loaded.

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"

As you can see the link in the first one is working. The one in the second one is not.

When I request the webpage normally, it will request the second link and it will cause 404 error as cannot find the path.

If i type directly the first link , the image was found.

I notice that c and d website are redirected when type the link.And this is the cause of the problem.

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

Here is my apache reverse proxy configuration

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    #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>

So , how do i solve this? I have been researching mod_rewrite and mod_proxy_html , but no luck in solving the problem.

share|improve this question

1 Answer 1

You can use seperate Location containers for the images.

I am not testing this but this should be more or less it.

For /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>

For /d I am not quite sure what is happenign, maybe there is a redirect on 1.1.1.4:8080 that redericts everything to /landing.do ? In this case the following would not help:

    <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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.