
Scenario
This is my scenario and use case.
A user visits /status on a website that I own, and I want the response to be OK.
curl https://localhost:8080/status
The above curl command should return OK.
Instead of creating a static file named static and stored in the root directory, I just want Nginx to send a textual response of OK.
Solution to send plaintext response
Open up the Nginx virtual host configuration file and add a location directive.
location "/status" {
default_type text/plain;
return 200 "OK";
}
Alternative Solution
An alternative is this location block with add_headers instead of default_type.
location "/status" {
add_header Content-Type text/plain
return 200 "OK";
}
Restart Nginx
sudo systemctl restart nginx
Verify plaintext response
After restarting Nginx, verify that you are getting OK as the response for /status.
curl https://localhost:8080/status
Your output will be this:
OK
Verify the content type and other headers
curl -I https://localhost:8080/status
Output:
HTTP/2 200
server: nginx/1.24.0
date: Wed, 16 Dec 2025 15:03:40 GMT
content-type: text/plain
content-length: 47
strict-transport-security: max-age=31536000; includeSubDomains; preload
As you can see, it is returning text/plain, which is what we want.
Conclusion
For this particular need, I personally prefer default_type text/plain; because everything following /status will be textual. You can use add_header depending on your scenario. Thanks for reading.
Related Posts
If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.