0
votes

I've installed Apache 2.4 on a Ubuntu 14.04.2 LTS box and added my site and everything works fine except a proxy rewrite rule for some images. The rule I have set up is as follows:

RewriteEngine on
RewriteRule /images/here/(.*)$ http://my.site.com/images/here/$1 [P,QSA,L]

However when I try to access a file say:

http://other.site.com/images/here/image.jpg

I get a 404 error in the browser. I switched on rewrite logging and in the log it would appear that it is matching the rules and applying the proxy correctly:

[Wed Sep 23 09:47:16.387531 2015] [rewrite:trace2] [pid 29527:tid 139709285484288] mod_rewrite.c(468): [client 10.0.5.61:51099] 10.0.5.61 - - [other.site.com/sid#7f109fe93400][rid#7f109fe070a0/initial] init rewrite engine with requested uri /images/here/image.jpg
[Wed Sep 23 09:47:16.387700 2015] [rewrite:trace3] [pid 29527:tid 139709285484288] mod_rewrite.c(468): [client 10.0.5.61:51099] 10.0.5.61 - - [other.site.com/sid#7f109fe93400][rid#7f109fe070a0/initial] applying pattern '/images/here/(.*)$' to uri '/images/here/image.jpg'
[Wed Sep 23 09:47:16.387736 2015] [rewrite:trace2] [pid 29527:tid 139709285484288] mod_rewrite.c(468): [client 10.0.5.61:51099] 10.0.5.61 - - [other.site.com/sid#7f109fe93400][rid#7f109fe070a0/initial] rewrite '/images/here/image.jpg' -> 'http://my.site.com/images/here/image.jpg'
[Wed Sep 23 09:47:16.387748 2015] [rewrite:trace2] [pid 29527:tid 139709285484288] mod_rewrite.c(468): [client 10.0.5.61:51099] 10.0.5.61 - - [other.site.com/sid#7f109fe93400][rid#7f109fe070a0/initial] forcing proxy-throughput with http://my.site.com/images/here/image.jpg
[Wed Sep 23 09:47:16.387757 2015] [rewrite:trace1] [pid 29527:tid 139709285484288] mod_rewrite.c(468): [client 10.0.5.61:51099] 10.0.5.61 - - [other.site.com/sid#7f109fe93400][rid#7f109fe070a0/initial] go-ahead with proxy request proxy:http://my.site.com/images/here/image.jpg [OK]

I've checked that mod_rewrite, mod_proxy and mod_proxy_http are all enabled an they are. I've also tried accessing the image using curl and wget from the server and it can get them image fine, so it is not a network issue with the server not managing to access the image.

This same rule works fine on Apache 2.2 on CentOS 6 and 7 boxes.

I'm at a loss now as to why it is not working. Maybe something else is required in 2.4?

Thanks.

1

1 Answers

0
votes

You've got two small issues:

Apache2.4 needs a different string-start anchor:

RewriteRule /images/here/

Should be:

RewriteRule ^images/here/

And your flags might cause issues: