Nginx return 444 depending on upstream response code

Posted by Mark on Server Fault See other posts from Server Fault or by Mark
Published on 2012-06-29T14:37:50Z Indexed on 2012/06/29 15:17 UTC
Read the original article Hit count: 171

Filed under:

I have nginx setup to pass to an upstream using proxy pass. The upstream is written to return a 502 http response on certain requests, rather then returning the 502 with all the header I would like nginx to recoginse this and return 444 so nothing is returned. Is this possible?

I also tried to return 444 on any 50x error but it doesn't work either.

location / {
    return 444;
}


location ^~ /service/v1/ {
    proxy_pass http://127.0.0.1:3333;
    proxy_next_upstream error timeout http_502;
    error_page  500 502 503 504  /50x.html;
}

location = /50x.html {
    return 444;
}

error_page  404              /404.html;
location = /404.html {
    return 444;
}

© Server Fault or respective owner

Related posts about nginx