I want to know how caddy-cgi passes PWD to CGI scripts.
If by PWD you mean current working directory (as in the Unix command
pwd), caddy-cgi does not pass that in the environment directly. However, the values associated with environment variable keys are all subject to placeholder substitution, just as with the script name and arguments, so you can pass the current working directory with the directive
If by PWD you mean password there are some different situations. If you use basic authentication, the CGI plugin will either not be run at all (if the authentication does not succeed) or it will run but not have access to the password (if authentication succeeds).
If you use your own username/password authentication in a form, the form values will be passed in the environment and you can retrieve them with the names of the form fields from the POST_DATA or QUERY_STRING environment variables. (For example, in PHP this might be
So I’m reading caddy-cgi source code ( https://github.com/jung-kurt/caddy-cgi ), but I did not understand at last how this plugin fork a process. I couldn’t find out any go code like “exec.Command()” in this repository. Then, how it forks a CGI process?
caddy-cgi lets the Go standard library handle this part. See host.go.