Reputation: 14798
If a file is not found, or forbidden, etc. -- I'd really like to just return the HTTP status code and no body content. Something like:
error_page 403 404 body="";
What are the current (2015) best practices?
Upvotes: 3
Views: 5675
Reputation: 2224
Realistically, all current options imply location per error code wich isn't a clean solution. When you compile your nginx, simply deal with bodies in src/http/ngx_http_special_response.c
Upvotes: -2
Reputation: 71
I am not sure if this is the best practise but it still works even without creating actual empty file.
error_page 403 404 /__empty-error-page__.html;
location = /__empty-error-page__.html {
internal;
return 200 "";
}
Upvotes: 7
Reputation: 14798
The best I've come up with is to create a zero-byte file:
$ touch _.json
set that location to be internal in my nginx config, and point the error_page to it:
location /_.json {
internal;
}
error_page 403 404 /_.json;
Depending on your content-type, replace _.json
with your desired _.mime-type-extension
.
Upvotes: 0