# Nginx as a reverse caching / load balancing solution - verification of setup needed

**URL:** <https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253>\
**Category:** NGINX\
**Created:** [September 4, 2015, 12:05pm UTC](https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253 "2015-09-04T12:05:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [September 4, 2015, 12:05pm UTC](https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253/1 "2015-09-04T12:05:29Z")

</div>

Good day Guys.

I would like to ask if someone could please verify my configs :

> **[root@chs-bctest01-v / # cat /etc/nginx/nginx.confuser www-data;worker\_proces...](https://pastebin.com/8Xk63RYD)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

> **[/etc/nginx/conf.d/loadbalance-upstream.confupstream loadbalance { serve -...](https://pastebin.com/EfNSpvMV)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

I have a Nginx server sitting in front of two Apache servers.  
I’m using Nginx as a reverse caching / load balancing solution.  
But what I’m trying achieve is to cache only for images, css and Js.

All in all it appears it all works.

The other question I would like to ask is, does the order of location  
matter?

If anyone can help, it would be appreciated.

Thanks  
Brent

---

<div class="post-metadata">

**Author:** ![brentmc79](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@brentmc79](https://www.ruby-forum.com/u/brentmc79)\
**Post date:** [September 4, 2015, 1:31pm UTC](https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253/2 "2015-09-04T13:31:21Z")

</div>

2015-09-04 12:04 GMT+02:00 Brent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> All in all it appears it all works.
> 
> The other question I would like to ask is, does the order of location  
> matter?

Depends. For regular expression based location is does, for prefix based  
locations it doesn’t. See

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#location)**
>
> This directive appeared in version 1.11.8.

A location can either be defined by a prefix string, or by a regular

>

---

<div class="post-metadata">

**Author:** ![brentmc79](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@brentmc79](https://www.ruby-forum.com/u/brentmc79)\
**Post date:** [September 4, 2015, 2:02pm UTC](https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253/3 "2015-09-04T14:02:54Z")

</div>

Thank you ever so much.

Regards  
Brent

---

<div class="post-metadata">

**Author:** ![brentmc79](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@brentmc79](https://www.ruby-forum.com/u/brentmc79)\
**Post date:** [September 4, 2015, 8:02pm UTC](https://www.ruby-forum.com/t/nginx-as-a-reverse-caching-load-balancing-solution-verification-of-setup-needed/243253/4 "2015-09-04T20:02:11Z")

</div>

Igor recommends using prefix locations as much as possible.  
If you were to use regex locations, you might want to embed them into  
prefix ones so order only matters at the leaves of the tree, which helps  
avoiding conflicts and makes you configuration scalable the most.

## Here is a presentation by Igor himself about the latter: [https://youtu.be/YWRYbLKsS0I](https://youtu.be/YWRYbLKsS0I)

_B. R._

On Fri, Sep 4, 2015 at 2:01 PM, Brent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
