# Limit file types that can be proxied

**URL:** <https://www.ruby-forum.com/t/limit-file-types-that-can-be-proxied/189271>\
**Category:** NGINX\
**Created:** [May 27, 2010, 8:20pm UTC](https://www.ruby-forum.com/t/limit-file-types-that-can-be-proxied/189271 "2010-05-27T20:20:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reference123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/858c86/32.png) [@reference123](https://www.ruby-forum.com/u/reference123)\
**Post date:** [May 27, 2010, 8:20pm UTC](https://www.ruby-forum.com/t/limit-file-types-that-can-be-proxied/189271/1 "2010-05-27T20:20:48Z")

</div>

I am trying to limit the file types that can be proxied from our backend  
server. I am trying to limit it to jpg, gif, png, css and then two  
other specific files - Thumbnail.ashx and hearbeat.htm. I am also  
hoping to limit access to only certain referers.

I have tried this code which works fine for the jpg, gif, png, css but  
is not working for the heartbeat.htm file. It gives a 404 on all .htm  
files including heartbeat.htm.

location ~\* (.jpg|.png|.gif|.css|ThumbNail.ashx|heartbeat.htm)$ {

```
valid_referers
  none
  blocked
  example.com
  www.example.com
  examplellimages.com
  www.examplellimages.com
  1.examplellimages.com
  2.examplellimages.com
  3.examplellimages.com
  4.examplellimages.com;

if ($invalid_referer) {
  return 404;
}

proxy_pass http://exampleimages_com;
}

```

Any help would be appreciated.

Posted at Nginx Forum:

> **[Limit file types that can be proxied](https://forum.nginx.org/read.php?2,91106,91106#msg-91106)**
>
> I am trying to limit the file types that can be proxied from our backend server. I am trying to limit it to jpg, gif, png, css and then two other specific files - Thumbnail.ashx and hearbeat.htm. I am also hoping to limit access to only certain...

---

<div class="post-metadata">

**Author:** ![reference123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/858c86/32.png) [@reference123](https://www.ruby-forum.com/u/reference123)\
**Post date:** [May 27, 2010, 8:43pm UTC](https://www.ruby-forum.com/t/limit-file-types-that-can-be-proxied/189271/2 "2010-05-27T20:43:38Z")

</div>

On Thu, May 27, 2010 at 11:19 AM, reference123 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> www.example.com
> 
> ```
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

Hello,

I’m not sure why heartbeat.htm is not captured there offhand, it seems  
correct on a quick look. Another way to separate heartbeat would be  
with an explicit location such as:

location = /heartbeat.htm { proxy\_pass [http://whatever](http://whatever); }

Thanks,  
Merlin
