# Recursive Error Pages or how to try more than one location

**URL:** <https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532>\
**Category:** NGINX\
**Created:** [June 22, 2010, 8:58am UTC](https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532 "2010-06-22T08:58:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elena\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@Elena\_Z](https://www.ruby-forum.com/u/Elena_Z)\
**Post date:** [June 22, 2010, 8:58am UTC](https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532/1 "2010-06-22T08:58:09Z")

</div>

Hello list,

i have to store images on 3 servers. Image processing runs on all of the  
3 servers and spreading the images over the 3 servers is a background  
task, so it takes some time the images are available on all 3 servers.

Nginx should try to fetch the image from an other server. But my  
configuration only works 1 level depth. Nginx never trys to fetch from  
location @s2 or @s3.

How can i configure nginx trying to find the image on all 3 server?

Any hints are welcome.

Thanks

server {

listen 80;  
root /var/www/nginx-default;

recursive\_error\_pages on;

```
location @s1 {
    internal;
    proxy_pass http://192.168.0.10;
    proxy_intercept_errors off;
    proxy_store on;
    proxy_store_access user:rw group:rw all:rw;
    proxy_temp_path /var/www/nginx-default/tmp;
    root /var/www/nginx-default;
    recursive_error_pages on;
    error_page 404 502 = @s2;
}

location @s2 {
    internal;
    proxy_pass http://192.168.0.20;
    proxy_store on;
    proxy_store_access user:rw group:rw all:rw;
    proxy_temp_path /var/www/nginx-default/tmp;
    root /var/www/nginx-default;
    recursive_error_pages on;
    error_page 404 502 = @s3;
}

location @s3 {
    internal;
    proxy_pass http://192.168.0.30;
    proxy_store on;
    proxy_store_access user:rw group:rw all:rw;
    proxy_temp_path /var/www/nginx-default/tmp;
    root /var/www/nginx-default;
    recursive_error_pages on;
    error_page 404 = /404.htm;
}

location ~* \.(jpg|jpeg)$ {
    root /var/www/nginx-default;
    error_page 404 = @node1;
}

```

## }

GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! [Aktuelle Nachrichten aus Politik, Wirtschaft & Panorama | GMX](http://portal.gmx.net/de/go/dsl)

---

<div class="post-metadata">

**Author:** ![Elena\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@Elena\_Z](https://www.ruby-forum.com/u/Elena_Z)\
**Post date:** [June 22, 2010, 9:03am UTC](https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532/2 "2010-06-22T09:03:25Z")

</div>

On Tue, Jun 22, 2010 at 08:57:15AM +0200, Elena Z. wrote:

> Hello list,
> 
> i have to store images on 3 servers. Image processing runs on all of the 3 servers and spreading the images over the 3 servers is a background task, so it takes some time the images are available on all 3 servers.
> 
> Nginx should try to fetch the image from an other server. But my configuration only works 1 level depth. Nginx never trys to fetch from location @s2 or @s3.
> 
> How can i configure nginx trying to find the image on all 3 server?
> 
> Any hints are welcome.

You should add

```
     proxy_intercept_errors off;

```

in @s2 and @s3.

However, there is a way to handle files in one location:

```
     proxy_next_upstream ... http_404 ...;

```

> ```
> location @s1 {
> 
> }
> 
> ```
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Elena\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@Elena\_Z](https://www.ruby-forum.com/u/Elena_Z)\
**Post date:** [June 22, 2010, 9:06am UTC](https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532/3 "2010-06-22T09:06:21Z")

</div>

On Tue, Jun 22, 2010 at 11:02:51AM +0400, Igor S. wrote:

> > Any hints are welcome.
> 
> You should add
> 
> ```
> proxy_intercept_errors off;
> 
> ```
> 
> in @s2 and @s3.

Sorry, you should set  
proxy\_intercept\_errors on;

in all @s1,2,3.

> > root /var/www/nginx-default;  
> > root /var/www/nginx-default;  
> > root /var/www/nginx-default;  
> > proxy\_temp\_path /var/www/nginx-default/tmp;  
> > }  
> > Igor S.  
> > [Igor Sysoev](http://sysoev.ru/en/)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Elena\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@Elena\_Z](https://www.ruby-forum.com/u/Elena_Z)\
**Post date:** [June 22, 2010, 9:30am UTC](https://www.ruby-forum.com/t/recursive-error-pages-or-how-to-try-more-than-one-location/190532/4 "2010-06-22T09:30:56Z")

</div>

Oh, yes that make sense… “intercept” 🙂 But i will try  
to use proxy\_next\_upstream.

Thanks a lot for your fast, very fast helpful answer.

nginx, you make my day :))

-------- Original-Nachricht --------

> Datum: Tue, 22 Jun 2010 11:05:36 +0400  
> Von: Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Betreff: Re: Recursive Error Pages or how to try more than one location

> > > 
> > 
> > ```
> > proxy_intercept_errors off;
> > proxy_next_upstream ... http_404 ...;
> > 
> > ```
> > 
> > > ```
> > > }
> > > }
> > > error_page 404 = /404.htm;
> > > 
> > > ```
> > > 
> > > Bis zu 150 EUR Startguthaben inklusive!
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
GRATIS fÃ¼r alle GMX-Mitglieder: Die maxdome Movie-FLAT!  
Jetzt freischalten unter [http://portal.gmx.net/de/go/maxdome01](http://portal.gmx.net/de/go/maxdome01)
