0

I have 2 servers one apache and one nginx.

I setup nginx as proxy

location / {
                proxy_pass http://apachesample.com:8080/;
                include /etc/nginx/conf.d/proxy.conf; 
                proxy_buffering off;
                proxy_cache web-cache;
                proxy_cache_valid 200 302 60m;
                proxy_cache_valid 404 1m;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;

                // try to add this section to add header and cache image
                location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                        expires max;
                        add_header Pragma public;
                        #add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                }

        }

All images are not found when i try to add expries header ?

How can i set cache expires header for images ? Do i have to do it on apache server ?

FIXED: enable mod_rewrite

Chameron
  • 109
  • 3
  • I am sorry but the question is a little unclear. Do you want nginx to cache images? What is the current behaviour you see with the configuration you have posted? What do you mean when you say images are not found? – ngn Jul 21 '15 at 10:34
  • when i try to open image by link domain.com/image.jpg and get not found 404. All source code is putted on apache server, so i want to cache images on nginx server – Chameron Jul 22 '15 at 03:46
  • I am not able to point out any issues in your configuration. Can you check [this question](http://serverfault.com/questions/494669/setting-up-a-reverse-proxy-to-cache-images) and see if it helps? – ngn Jul 22 '15 at 09:59
  • I did not enable mode rewrite on apache server – Chameron Jul 23 '15 at 01:46
  • Is the issue fixed after you enabled mod rewrite? If yes, can you please update your question with that information? – ngn Jul 23 '15 at 09:12

0 Answers0