# Image files (jpg,png) could not be opened

**URL:** <https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743>\
**Category:** NGINX\
**Created:** [February 4, 2011, 8:09pm UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743 "2011-02-04T20:09:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 4, 2011, 8:09pm UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743/1 "2011-02-04T20:09:42Z")

</div>

Hi all,  
Image files like .png and .jpg could not be opened when click on it. It  
works fine for others like .txt or .xls. I got a prompt window where I  
can select a program to open the file but for image files I got 404  
error page.  
mime.types file is in place and has image types.  
Any help would be great,  
Thanks a lot,  
Irina

Posted at Nginx Forum:

> **[Image files (jpg,png) could not be opened.](https://forum.nginx.org/read.php?2,172228,172228#msg-172228)**
>
> Hi all, Image files like .png and .jpg could not be opened when click on it. It works fine for others like .txt or .xls. I got a prompt window where I can select a program to open the file but for image files I got 404 error page. mime.types file is...

---

<div class="post-metadata">

**Author:** ![Irina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Irina](https://www.ruby-forum.com/u/Irina)\
**Post date:** [February 4, 2011, 11:37pm UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743/2 "2011-02-04T23:37:24Z")

</div>

The problem is solved. nginx does not send any request to thr server if  
the file extension is .png or .jpg. The solution is to sedn this request  
if file name is matched up with image file extension. Add this line to  
nginx.conf:  
location ~ .png$ {  
proxy\_pass [http://mongrel](http://mongrel);  
}

The more general solution is to match an url, something like that:  
location ^~/insight/show\_file/ {  
proxy\_pass [http://mongrel](http://mongrel);  
}

Both wok fine for me.  
Maybe it will be helpful for somebody,  
Thanks,  
Irina

Posted at Nginx Forum:

> **[Re: Image files (jpg,png) could not be opened.](https://forum.nginx.org/read.php?2,172228,172268#msg-172268)**
>
> Hi all, Image files like .png and .jpg could not be opened when click on it. It works fine for others like .txt or .xls. I got a prompt window where I can select a program to open the file but for image files I got 404 error page. mime.types file is...

---

<div class="post-metadata">

**Author:** ![Irina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Irina](https://www.ruby-forum.com/u/Irina)\
**Post date:** [February 5, 2011, 7:22am UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743/3 "2011-02-05T07:22:08Z")

</div>

On Fri, 2011-02-04 at 17:35 -0500, Irina wrote:

> The problem is solved. nginx does not send any request to thr server if  
> the file extension is .png or .jpg.

This isn’t true, unless you’ve configured it this way.

> ```
> }
> 
> ```

What I would suggest, if you want help with your configuration, is to  
post your config here so that people can see what you are trying to do.

Cliff

---

<div class="post-metadata">

**Author:** ![Irina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Irina](https://www.ruby-forum.com/u/Irina)\
**Post date:** [February 7, 2011, 5:00pm UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743/4 "2011-02-07T17:00:00Z")

</div>

Yes, you are right, I have this line in my config that conflicts when I  
would like to open any image files.  
location ~\* .(ico|css|gif|js|jpe?g|png)(?[0-9]+)?$ {  
add\_header Cache-Control “must-revalidate”;  
expires max;  
break;  
}  
But I need it otherwise pages will be loading extremely slow. So this  
line along with my previous updates give me the correct behavior.  
Thanks,  
Irina

Posted at Nginx Forum:

> **[Re: Image files (jpg,png) could not be opened.](https://forum.nginx.org/read.php?2,172228,172890#msg-172890)**
>
> Hi all, Image files like .png and .jpg could not be opened when click on it. It works fine for others like .txt or .xls. I got a prompt window where I can select a program to open the file but for image files I got 404 error page. mime.types file is...

---

<div class="post-metadata">

**Author:** ![Irina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Irina](https://www.ruby-forum.com/u/Irina)\
**Post date:** [February 15, 2011, 5:55am UTC](https://www.ruby-forum.com/t/image-files-jpg-png-could-not-be-opened/202743/5 "2011-02-15T05:55:51Z")

</div>

I like to re-arrange my images within a file, placing related images  
next to each other, regardless of the order that I photographed them in  
(e.g. a macro shot of a building and a detail shot of the same building  
photographed on a different day). Or, when doing a slide show I might  
put comparable images next to each other. I have always been able to do  
this while I had Windows XP and older programmes. Now I have Windows 7  
and it wont let me move my images around - they just jump straight back  
to the slot the computer has ‘chosen’ when I try to drag and drop one.  
This is ridiculous!  
What do I have to do to bypass the alph-numerical system - PLEASE can  
someone help me!

Thanks! Helen
