cgi

cgi (common gateway interface) allows you to generate dynamic content using shell scripts. nginx is configured to treat anything ending in '.sh' as a cgi script.

how cgi works

when a request is made to a .sh file, the server executes the script and returns its output to the browser. the script must output valid thtp headers followed by the content.

example

create a file with the .sh extension in your public_html directory:

#!/bin/bash

# Required: Output the Content-Type header followed by a blank line
echo "Content-Type: text/html"
echo ""

# Now output the HTML content
echo "Current time: $(date)"
echo "Your IP: $REMOTE_ADDR"

your script must be executable:

chmod +x script.sh

security

try not to accidentally grant internet randos arbitrary code execution using CGI!