# 502 in Nginx as a reverse proxy whithout cache

**URL:** <https://www.ruby-forum.com/t/502-in-nginx-as-a-reverse-proxy-whithout-cache/236042>\
**Category:** NGINX\
**Created:** [August 1, 2013, 12:17pm UTC](https://www.ruby-forum.com/t/502-in-nginx-as-a-reverse-proxy-whithout-cache/236042 "2013-08-01T12:17:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 1, 2013, 12:17pm UTC](https://www.ruby-forum.com/t/502-in-nginx-as-a-reverse-proxy-whithout-cache/236042/1 "2013-08-01T12:17:59Z")

</div>

Hi,

Currently, we use Nginx as a reverse proxy without cache. Last monday  
we’ve  
rolled out a new version of PHP application which has appeared a several  
502  
errors.

First of all, i’ve applied the workaround explained in thread  
[502 errors, upstream sent too big header](http://forum.nginx.org/read.php?2,188352) . The number of 502 have falled  
down but we can see a several 502 yet, but we haven’t any error log now  
in  
the nginx.

This is Nginx parameters applied:  
{code}

## Size Limits

client\_body\_buffer\_size 128K;  
client\_header\_buffer\_size 1M;  
client\_max\_body\_size 1M;  
large\_client\_header\_buffers 8 8k;

## Timeouts

client\_body\_timeout 600;  
client\_header\_timeout 600;  
expires 24h;  
keepalive\_timeout 60 60;  
send\_timeout 600;

## TCP options

tcp\_nodelay on;  
tcp\_nopush on;

## Proxy caching options

proxy\_buffering on;  
proxy\_buffers 16 16k;  
proxy\_buffer\_size 32k;

fastcgi\_buffers 16 16k;  
fastcgi\_buffer\_size 32k;

proxy\_next\_upstream error timeout http\_500 http\_502 http\_503 http\_504;  
proxy\_connect\_timeout 60s;  
proxy\_read\_timeout 600s;  
proxy\_send\_timeout 600s;  
{code}

This is the trace lines in acces log of Nginx and Apache:

Las trazas son estas:  
NGINX  
log\_format main '$remote\_addr - $remote\_user [$time\_local] “$request”  
’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;  
{code}  
2.139.8.108 - - [31/Jul/2013:23:19:31 +0200] “GET  
/es/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm\_campaign=AAAAA&utm\_content=AAAAAAA&utm\_medium=email&utm\_source=ExactTarget&email=removed\_email\_address@domain.invalid&date=AAAAAAA&AL\_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm\_referrer=  
HTTP/1.1” 502 118  
“[http://es.example.com/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm\_campaign=AAAAA&utm\_content=AAAAAAA&utm\_medium=email&utm\_source=ExactTarget&email=removed\_email\_address@domain.invalid&date=AAAAAAA&AL\_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA](http://es.example.com/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm_campaign=AAAAA&utm_content=AAAAAAA&utm_medium=email&utm_source=ExactTarget&email=removed_email_address@domain.invalid&date=AAAAAAA&AL_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)”  
“Mozilla/5.0 (Linux; U; Android 2.3.3; es-es; GT-I9100  
Build/GINGERBREAD)  
AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1”  
“-”  
{code}

LogFormat “"%{True-Client-IP}i" %h %t %T "%r" %\>s %b  
%{outstream}n/%{instream}n (%{ratio}n%%) "%{Referer}i" "%{Expires}o"  
"%{Cache-Control}o" "%{User-Agent}i" "%{Host}i"  
"%{X-Forwarded-For}i" %{mod\_php\_memory\_usage}n %P” itsysprod

APACHE  
{code}  
“-” 10.253.1.61 [31/Jul/2013:23:19:31 +0200] 0 “GET  
/es/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm\_campaign=AAAAA&utm\_content=AAAAAAA&utm\_medium=email&utm\_source=ExactTarget&email=removed\_email\_address@domain.invalid&date=AAAAAAA&AL\_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA  
HTTP/1.0” 200 303 285/475 (60%)  
“[http://es.example.com/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm\_campaign=AAAAA&utm\_content=AAAAAAA&utm\_medium=email&utm\_source=ExactTarget&email=removed\_email\_address@domain.invalid&date=AAAAAAA&AL\_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA](http://es.example.com/descuentos-malaga/oferta-pelsandbody-masaje-tailandes-aromaterapia.html?mktc=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&utm_campaign=AAAAA&utm_content=AAAAAAA&utm_medium=email&utm_source=ExactTarget&email=removed_email_address@domain.invalid&date=AAAAAAA&AL_Hash=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)”  
“Thu, 19 Nov 1981 08:52:00 GMT” “no-store, no-cache, must-revalidate,  
post-check=0, pre-check=0” “Mozilla/5.0 (Linux; U; Android 2.3.3; es-es;  
GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko)  
Version/4.0 Mobile Safari/533.1” “[m.example.com](http://m.example.com)” “2.139.8.108,  
10.253.1.60”  
786432 30962  
{code}

Platform description

# cat /etc/redhat-release

CentOS release 6.3 (Final)

# uname -a

Linux balance01-prod 2.6.32-279.5.2.el6.x86\_64 #1 SMP Fri Aug 24  
01:07:11  
UTC 2012 x86\_64 x86\_64 x86\_64 GNU/Linux

# nginx -v

nginx version: nginx/1.2.4

Posted at Nginx Forum:

> **[502 in Nginx as a reverse proxy whithout cache](https://forum.nginx.org/read.php?2,241447,241447#msg-241447)**
>
> Hi, Currently, we use Nginx as a reverse proxy without cache. Last monday we've rolled out a new version of PHP application which has appeared a several 502 errors. First of all, i've applied the workaround explained in thread...

---

<div class="post-metadata">

**Author:** ![marc.cortinas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@marc.cortinas](https://www.ruby-forum.com/u/marc.cortinas)\
**Post date:** [August 2, 2013, 2:26pm UTC](https://www.ruby-forum.com/t/502-in-nginx-as-a-reverse-proxy-whithout-cache/236042/2 "2013-08-02T14:26:11Z")

</div>

I’ve found the error in the backend server, not in Nginx.  
We can close this thread, apologies!

Posted at Nginx Forum:

> **[Re: 502 in Nginx as a reverse proxy whithout cache](https://forum.nginx.org/read.php?2,241447,241477#msg-241477)**
>
> Hi, Currently, we use Nginx as a reverse proxy without cache. Last monday we've rolled out a new version of PHP application which has appeared a several 502 errors. First of all, i've applied the workaround explained in thread...

---

<div class="post-metadata">

**Author:** ![marc.cortinas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@marc.cortinas](https://www.ruby-forum.com/u/marc.cortinas)\
**Post date:** [August 1, 2013, 12:53pm UTC](https://www.ruby-forum.com/t/502-in-nginx-as-a-reverse-proxy-whithout-cache/236042/3 "2013-08-01T12:53:38Z")

</div>

I’ve upgraded the nginx version 1.24 to 1.4.2, but this behavior still  
happens.

Posted at Nginx Forum:

> **[Re: 502 in Nginx as a reverse proxy whithout cache](https://forum.nginx.org/read.php?2,241447,241459#msg-241459)**
>
> Hi, Currently, we use Nginx as a reverse proxy without cache. Last monday we've rolled out a new version of PHP application which has appeared a several 502 errors. First of all, i've applied the workaround explained in thread...
