502 Bad Gateway when downloading file

Maxim Dounin mdounin at mdounin.ru
Sun Oct 16 12:31:29 UTC 2011


Hello!

On Sun, Oct 16, 2011 at 07:24:34AM -0400, sogi wrote:

> Hello.
> Many thanks for your reply.
> We are changing headers through PHP header() function.
> 
> Header is dispatching correctly from HAPROXY. It is as follows:
> HTTP/1.1 200 OK                                                         
>                                                                         
>                                     
> Date: Fri, 14 Oct 2011 01:18:08 GMT                                     
>                                                                         
>                                     
> Server: Apache/2.2.16 (Debian)                                          
>                                                                         
>                                     
> X-Powered-By: PHP/5.2.10                                                
>                                                                         
>                                     
> Expires: Thu, 19 Nov 1981 08:52:00 GMT                                  
>                                                                         
>                                     
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0                                                             
>                                            
> Pragma: no-cache                                                        
>                                                                         
>                                     
> Content-Length: 77032;                                                  

The ";" is incorrect and shouldn't be here.  If it's indeed 
present in headers returned by your backend - there is no surprise 
haproxy rejects such responses (see below).

>                                                                         
>                                     
> Content-Disposition: attachment; filename="aaaa.txt"                    
>                                                                         
>                                   
> Connection: close                                                       
>                                                                         
>                                     
> Content-Type: application/txt              
> 
> Logs from nginx debug:
> http://pastebin.com/UrMXgYyf
> (I have more - all from logging into system to 502, but there are so
> large actually :) )

Debug log shows response from backend was already 502:

2011/10/13 21:47:05 [debug] 15881#0: *33 http proxy status 502 "502 Bad Gateway"

That is, most likely it's haproxy who returned 502.  See above for 
possible reason.

Maxim Dounin



More information about the nginx mailing list