Monday | 15 APR 2024
[ previous ]
[ next ]

Returning Strings in Nginx

Date: 2022-11-17

This was a proof of concept for my form submission note. I wanted to have nginx send back a response when it got some post data. I would have loved to have returned the post data itself but for some reason request_body was blank and I didn't want to dig into it.

Regardless, returning just a string worked perfectly!

server {
    location /some-endpoint {
        if ($request_method = POST ) {
            add_header Content-Type text/plain;
            return 200 'Processed!';

This block simply returns back some text if it receives a POST request.

This is for: