# Dropbox as upsream server

**URL:** <https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147>\
**Category:** NGINX\
**Created:** [April 11, 2013, 10:15am UTC](https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147 "2013-04-11T10:15:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![winniethepooh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc8723/32.png) [@winniethepooh](https://www.ruby-forum.com/u/winniethepooh)\
**Post date:** [April 11, 2013, 10:15am UTC](https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147/1 "2013-04-11T10:15:42Z")

</div>

I’m trying to use the Dropbox public folder and my nginx server as a  
upstream server to server static files. I’m hoping someone can point me  
in  
the right direction or tell me what I’m doing wrong.

So:  
[my.domain.net/u/#########/](http://my.domain.net/u/#########/)_.bz2 serves from  
 [http://dl.dropbox.com/u/#########/\*.bz2](http://dl.dropbox.com/u/#########/*.bz2) “twice” as much as  
 [my.domain.net/u/#########/](http://my.domain.net/u/#########/)_.bz2

It seems when the server uses the x.x.x.x:80 it loops and hits the  
proxy\_pass directive over and over resulting in a 500 error.

Any help is appreciated!

Here is what my configuration looks like:  
upstream backend {  
server x.x.x.x:80 weight=1 max\_fails=2;  
server [dl.dropbox.com:80](http://dl.dropbox.com:80) weight=2 max\_fails=2;  
}

server {  
listen 80;  
server\_name [my.domain.net](http://my.domain.net) [www.my.domain.net](http://www.my.domain.net);  
root /path/to/my/root/;

```
location /u/#########/ {
    autoindex on;
    autoindex_exact_size off;
            }

location ~* ^.+.(bz2|bsp|nav)$ {
            proxy_pass http://backend;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
    }

```

}

Posted at Nginx Forum:

> **[Dropbox as upsream server](https://forum.nginx.org/read.php?2,238280,238280#msg-238280)**
>
> I'm trying to use the Dropbox public folder and my nginx server as a upstream server to server static files. I'm hoping someone can point me in the right direction or tell me what I'm doing wrong. So: my.domain.net/u/#########/\*.bz2 serves from...

---

<div class="post-metadata">

**Author:** ![winniethepooh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc8723/32.png) [@winniethepooh](https://www.ruby-forum.com/u/winniethepooh)\
**Post date:** [April 11, 2013, 1:05pm UTC](https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147/2 "2013-04-11T13:05:42Z")

</div>

Hello!

On Thu, Apr 11, 2013 at 04:15:02AM -0400, winniethepooh wrote:

> proxy\_pass directive over and over resulting in a 500 error.
> 
> Any help is appreciated!
> 
> Here is what my configuration looks like:  
> upstream backend {  
> server x.x.x.x:80 weight=1 max\_fails=2;  
> server dl.dropbox.com:80 weight=2 max\_fails=2;  
> }

It’s not clear why you added “x.x.x.x” to the upstream block if  
it’s not an upstream but the same server. Obvious solution would  
be to remove it.

If you try to implement “check the local disk, and if the file  
isn’t there - proxy to dropbox” logic, correct solution would be  
to use something similar to an example provided at

> **[Alphabetical index of directives](http://nginx.org/en/docs/dirindex.html)**

```
location / {
    error_page 404 = @fallback;
}

location @fallback {
    proxy_pass http://backend;
}

```

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![winniethepooh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc8723/32.png) [@winniethepooh](https://www.ruby-forum.com/u/winniethepooh)\
**Post date:** [April 11, 2013, 5:09pm UTC](https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147/3 "2013-04-11T17:09:23Z")

</div>

## Maxim D. Wrote:

> ## to use something similar to an example provided at
> 
> Maxim D.  
> [nginx: donation](http://nginx.org/en/donation.html)

Hey, thanks for your reply! I have the same files stored both at  
/path/to/my/root/\* and at [http://dl.dropbox.com/u/#########/](http://dl.dropbox.com/u/#########/)\*. The same  
folder structure and everything.

What I want is to “load balance” between dropbox and the same nginx site  
(x.x.x.x) so both places can serve files.

Is the only way to do this to split up the proxy as one server block on  
one  
port (80 for example) and the actual server block hosting the files in  
another server block on a different server port (8080 for example)?

Or can I modify the originally posted setup to do what I want?

Thanks again.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,238280,238296#msg-238296](http://forum.nginx.org/read.php?2,238280,238296#msg-238296)

---

<div class="post-metadata">

**Author:** ![winniethepooh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc8723/32.png) [@winniethepooh](https://www.ruby-forum.com/u/winniethepooh)\
**Post date:** [April 11, 2013, 5:45pm UTC](https://www.ruby-forum.com/t/dropbox-as-upsream-server/228147/4 "2013-04-11T17:45:40Z")

</div>

Hello!

On Thu, Apr 11, 2013 at 11:08:47AM -0400, winniethepooh wrote:

> > If you try to implement "check the local disk, and if the file  
> > }  
> > (x.x.x.x) so both places can serve files.  
> > Ok, so you are you trying to save disk bandwidth at cost of  
> > network one.

> Is the only way to do this to split up the proxy as one server block on one  
> port (80 for example) and the actual server block hosting the files in  
> another server block on a different server port (8080 for example)?
> 
> Or can I modify the originally posted setup to do what I want?

Using distinct server blocks is most simple option.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
