Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can proxied image headers be modified on Apache?

We proxy images as licensed content and need to add max-age headers to the proxied images. Attempted modifying .htaccess, but it didn't work and suspect this is due to the proxied image folder not being an actual directory on the server.

First, the proxy is set up in apache2.conf:

# Image Proxy
ProxyPass /photo http://photo.licensor.com
ProxyPassReverse /photo http://photo.licensor.com

Made several attempts to modify .htaccess under the site's public_html directory. It appears that the condition to modify the max-age header for proxied images is never recognized by Apache since /photo is not a real directory.

I'd really like to target ONLY the proxied images using the /photo directory that isn't real.

like image 660
fantisy Avatar asked Oct 19 '22 13:10

fantisy


1 Answers

You can't use a <location> container in an htaccess file. It's probably best to put this in your apache server config file next to your ProxyPass settings:

<LocationMatch "/photo">
  # Image Proxy
  ProxyPass http://photo.licensor.com
  ProxyPassReverse http://photo.licensor.com
  Header unset Etag 
  Header set Cache-Control "max-age=86400, public" 
  Header unset Expires
</LocationMatch>
like image 123
Jon Lin Avatar answered Oct 24 '22 14:10

Jon Lin