# Reverse Cache for Multiple Sites

**URL:** <https://www.ruby-forum.com/t/reverse-cache-for-multiple-sites/207894>\
**Category:** NGINX\
**Created:** [June 5, 2011, 8:04pm UTC](https://www.ruby-forum.com/t/reverse-cache-for-multiple-sites/207894 "2011-06-05T20:04:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 5, 2011, 8:04pm UTC](https://www.ruby-forum.com/t/reverse-cache-for-multiple-sites/207894/1 "2011-06-05T20:04:48Z")

</div>

I am looking to implement NGINX as a reverse proxy cache for a number  
of sites, there are 6 fairly busy sites between 4 webservers. I can  
find plenty of online assistance in configuring NGINX to reverse cache  
a single site from a single origin. I appear to be struggling to find  
how to configure a single NGINX installation to reverse cache multiple  
sites from multiple origins.

Could anyone point me in the right direction on this, or am I overly  
complicating a simple config?

Thanks in advance,

John

---

<div class="post-metadata">

**Author:** ![John\_Macleod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@John\_Macleod](https://www.ruby-forum.com/u/John_Macleod)\
**Post date:** [June 5, 2011, 10:48pm UTC](https://www.ruby-forum.com/t/reverse-cache-for-multiple-sites/207894/2 "2011-06-05T22:48:04Z")

</div>

Hello!

On Sun, Jun 05, 2011 at 07:04:09PM +0100, John Macleod wrote:

> I am looking to implement NGINX as a reverse proxy cache for a number  
> of sites, there are 6 fairly busy sites between 4 webservers. I can  
> find plenty of online assistance in configuring NGINX to reverse cache  
> a single site from a single origin. I appear to be struggling to find  
> how to configure a single NGINX installation to reverse cache multiple  
> sites from multiple origins.
> 
> Could anyone point me in the right direction on this, or am I overly  
> complicating a simple config?

Just define multiple servers and configure them. See here for  
details:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Something like this should work:

```
proxy_cache_path /path/to/cache keys_zone=one:10m;

server {
    listen ...
    server_name site1.example.com;

    location / {
        proxy_pass http://site1.backend;
        proxy_cache one;
    }
}

server {
    listen ...
    server_name site2.example.com;

    location / {
        proxy_pass http://site2.backend;
        proxy_cache one;
    }
}

```

Maxim D.
