This page is about Caddy 1 and will go away soon because Caddy 2 is now available. Click here for Caddy 2.

User Guide

http.cgi
Plugin

This plugin implements the Common Gateway Interface (CGI) for Caddy. It lets you generate dynamic content on your website by means of command line scripts. To collect information about the inbound HTTP request, your script examines certain environment variables such as PATH_INFO and QUERY_STRING. Then, to return a dynamically generated web page to the client, your script simply writes content to standard output. In the case of POST requests, your script reads additional inbound content from standard input.

Full documentation

Examples

Simple CGI script
In the Caddyfile: cgi /report /usr/local/cgi-bin/report In /usr/local/cgi-bin/report: #!/bin/bash printf "Content-type: text/plain\n\n" printf "PATH_INFO [%s]\n" $PATH_INFO printf "QUERY_STRING [%s]\n" $QUERY_STRING exit 0

When a request such as https://example.com/report or https://example.com/report/weekly arrives, the cgi middleware will detect the match and invoke the script named /usr/local/cgi-bin/report. The environment variables PATH_INFO and QUERY_STRING are populated and passed to the script automatically. There are a number of other standard CGI variables included that are described in the documentation. If you need to pass any special environment variables or allow any environment variables that are part of Caddy's process to pass to your script, you will need to use the advanced directive syntax described in the documentation.

Related Links
Documentation

Access the full documentation for this plugin off-site:

Docs
Plugin Help

Get help from the maintainers of the http.cgi plugin:

Support
Plugin Website

Visit http.cgi's website for more information:

Website
Plugin Author: Kurt Jung
Last Updated: 23 May 2017, 4:18 PM
This plugin is independent of the Caddy project and is not endorsed or maintained by Caddy developers. Use at your own risk. Do not file issues for this plugin on Caddy's bug tracker.