NGINX 301 and 302 serving small nginx document body. Any way to remove this behaviour?

Posted by anonymous-one on Server Fault See other posts from Server Fault or by anonymous-one
Published on 2012-08-28T12:57:05Z Indexed on 2012/08/31 15:41 UTC
Read the original article Hit count: 278

Filed under:
|
|

We have noticed that when using nginx internal 301 and 302 handling, nginx will serve a small document body with the appropriate Location: ... header.

Something along the lines of (in html): 301 redirect - nginx.

As appropriate in the above behaviour, a content-type text/html and content-length header is also sent.

We do a lot of 302 and some 301 redirects, the above behaviour is wasted bandwidth in our opinion.

Any way to disable this behaviour?

One idea that crossed our mind was to set error_page 301 302 to an empty text file. We have not tested this yet, but I am assuming even with the above, the content-type and content-length (0) headers will be sent.

So, is there a clean way to send a "body-less" 301/302 redirect with nginx?

© Server Fault or respective owner

Related posts about nginx

Related posts about redirect