# Load balancer on nginx : how to monitoring backend?

**URL:** <https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950>\
**Category:** NGINX\
**Created:** [January 27, 2016, 6:11pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950 "2016-01-27T18:11:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [January 27, 2016, 6:11pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/1 "2016-01-27T18:11:16Z")

</div>

Hello everyone,

I use nginx 1.8.0 on debian (official nginx package with nginx repo)

I created a reverse proxy SSL cluster with load balancing. Everything  
works fine.

* * *

## upstream myapp { server srv1; server srv2; }

* * *

## location ~ ^/myapp { rewrite ^/(.\*) /$1 break; proxy\_pass [http://myapp](http://myapp); }

However I wish to monitor the status of the backend. How can I do ?

Thank you.

## compiler option

## built by gcc 4.9.2 (Debian 4.9.2-10) built with OpenSSL 1.0.1k 8 Jan 2015 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client\_temp –http-proxy-temp-path=/var/cache/nginx/proxy\_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi\_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi\_temp –http-scgi-temp-path=/var/cache/nginx/scgi\_temp --user=nginx –group=nginx --with-http\_ssl\_module --with-http\_realip\_module –with-http\_addition\_module --with-http\_sub\_module –with-http\_dav\_module --with-http\_flv\_module --with-http\_mp4\_module –with-http\_gunzip\_module --with-http\_gzip\_static\_module –with-http\_random\_index\_module --with-http\_secure\_link\_module –with-http\_stub\_status\_module --with-http\_auth\_request\_module –with-mail --with-mail\_ssl\_module --with-file-aio –with-http\_spdy\_module --with-cc-opt=‘-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D\_FORTIFY\_SOURCE=2’ –with-ld-opt=‘-Wl,-z,relro -Wl,–as-needed’ --with-ipv6

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 27, 2016, 8:40pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/2 "2016-01-27T20:40:15Z")

</div>

Hello!

On Wed, Jan 27, 2016 at 9:10 AM, Alexandre wrote:

> However I wish to monitor the status of the backend. How can I do ?

You may find the lua-resty-upstream-healthcheck library helpful:

```
https://github.com/openresty/lua-resty-upstream-healthcheck

```

But it’s much easier to install via the OpenResty bundle though:

```
https://openresty.org/

```

Regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 27, 2016, 11:33pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/3 "2016-01-27T23:33:11Z")

</div>

Monitoring of backend seems to be possible with NGINX PLUS. Can you  
confirm ?

[http://nginx.org/en/docs/http/ngx\_http\_upstream\_module.html](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)  
[https://www.nginx.com/products/](https://www.nginx.com/products/)

Thank you

Alexande.

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 27, 2016, 10:38pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/4 "2016-01-27T22:38:16Z")

</div>

Hello, thank you I’ll test.

It is not possible to test the nginx upstream directly ?

Thank you

Alexandre

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 28, 2016, 8:28am UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/5 "2016-01-28T08:28:18Z")

</div>

On 1/28/16 1:32 AM, Alexandre wrote:

> Monitoring of backend seems to be possible with NGINX PLUS. Can you  
> confirm ?
> 
> [Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)  
> [NGINX | F5](https://www.nginx.com/products/)

Yes, that’s right.

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

–  
Maxim K.

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 28, 2016, 10:27pm UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/6 "2016-01-28T22:27:11Z")

</div>

Hi.

Am 28-01-2016 08:36, schrieb Alexandre:

> > Yes, that’s right.
> 
> OK, I can not use a load balancer in production without backend  
> monitoring. I will use LVS.

just for my curiosity why can’t buying n+, for production!?

BR Aleks

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 28, 2016, 8:37am UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/7 "2016-01-28T08:37:04Z")

</div>

Hello,

On 28/01/16 08:27, Maxim K. wrote:

> On 1/28/16 1:32 AM, Alexandre wrote:
> 
> > Monitoring of backend seems to be possible with NGINX PLUS. Can you  
> > confirm ?
> > 
> > [Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)  
> > [NGINX | F5](https://www.nginx.com/products/)
> 
> Yes, that’s right.

OK, I can not use a load balancer in production without backend  
monitoring. I will use LVS.

Thank you.

Alexandre.

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 29, 2016, 5:54am UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/8 "2016-01-29T05:54:41Z")

</div>

Does anyone know if the author still maintains  
nginx\_upstream\_check\_module?  
I see only a handful of commits in the past year and they all look like  
contributed changes.

On Thu, Jan 28, 2016 at 9:28 PM, Dewangga Bachrul Alam \<

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 29, 2016, 7:28am UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/9 "2016-01-29T07:28:10Z")

</div>

Hello

On 28/01/16 22:26, Aleksandar L. wrote:

> > > > [Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)  
> > > > [NGINX | F5](https://www.nginx.com/products/)
> > > 
> > > Yes, that’s right.
> > 
> > OK, I can not use a load balancer in production without backend  
> > monitoring. I will use LVS.
> 
> just for my curiosity why can’t buying n+, for production!?

First I do not know the price of nginx plus. Moreover I do not think  
it’s a good idea to use a reverse proxy TLS and load balancing on the  
same machine when there is high web traffic. I preferred to separate  
processes. Nginx for reverse proxy TLS and LVS + Varnish for load  
balancing and cache.

> BR Aleks

Regards,  
Alexandre.

---

<div class="post-metadata">

**Author:** ![alexandre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@alexandre](https://www.ruby-forum.com/u/alexandre)\
**Post date:** [January 29, 2016, 3:28am UTC](https://www.ruby-forum.com/t/load-balancer-on-nginx-how-to-monitoring-backend/243950/10 "2016-01-29T03:28:37Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA256

Hello!

If you are in development, you can try this module  
[GitHub - yaoweibin/nginx\_upstream\_check\_module: Health checks upstreams for nginx · GitHub](https://github.com/yaoweibin/nginx_upstream_check_module). But, not  
recommended if use on production, better use n+.

On 01/28/2016 02:36 PM, Alexandre wrote:

> > Yes, that’s right.
> > 
> > > > > You may find the lua-resty-upstream-healthcheck library  
> > > > > helpful:
> > > > > 
> > > > > [GitHub - openresty/lua-resty-upstream-healthcheck: Health Checker for Nginx Upstream Servers in Pure Lua · GitHub](https://github.com/openresty/lua-resty-upstream-healthcheck)

But it’s much easier to install via the OpenResty bundle though:

> > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing  
> > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing list  
> > > > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)  
> > > > -----BEGIN PGP SIGNATURE-----  
> > > > Version: GnuPG v2

iQIcBAEBCAAGBQJWqs5DAAoJEOV/0iCgKM1wIAcP/inWjW0CGSQ1R0zDkwi+j5Ac  
m3LVzIS86/Ft86BuJXcam3SC5Cf+1bCYM0rUsYx5xsTZMjnJhOOkLaPFSGJ4jwth  
E3Lu5qDckCttOdmndmWXPUWHdTLASJXjntLEQgY969h48ucJRoCmA3ZB9DsPql7e  
nJS4Rkcu9DV4bSiCB6gFMNUksI9em/G6N/P2kXkEl33I9wEi79O7y5sT16dXiGm0  
vTp5qozO2UtGtO6lfx3s0xYxUpsSiLYtYlfAY6335cuh1yFQqhMyNr2EgphtlY+1  
cMMQnlM8Sfut0YltRcV3YSq1d8je4QEXSK0mC8sSXJUE58V/C6otu/O1I/h1BnQO  
g0TKFDTQk1rN1/z3b9jirlObwdNbWmIq7hI9Nuwi3WilDB57iEoD+pmC7R2obKDS  
ItrkkAKWWTsDyQOH2BMCK4nqW+whHC7D3lFCrKuzsITJDrFJf6fjzlXRzniwH/1L  
VJgKaIlnX7M54zJwITZcDcYGmLuC/MRHNU9HK3QYDgwdPdgSccDQwlhBnxI7tNtS  
gSaEVpf9Af/8QIPPyLngvl6uGskvfQdXiWHmRb0SyTwZcJEDrutf6q//hwT59Mn4  
ZFLS7htPV8wCKvgxlFV7DtxRcbm9HBDRdt1ScrbTKQbLAxxQhpOVCV1emhFjfgem  
020FGHFbMMmngyi50b1p  
=XA04  
-----END PGP SIGNATURE-----
