Caddy with Perl FastCGI setup

1. Caddy version (caddy version):

Version 2

2. How I run Caddy:

I have a production web site running on Windows IIS 10. with Perl CGI. All is well except is Windows and is very slow. I am hoping to migrate to Linux Ubuntu and convert CGI to FastCGI. I have a test server setup and can serve static HTML pages from Caddy. Https is working also. I am trying to figure out how to set up FastCGI with Perl. In IIS 10 I am using old style CGI. Any help would be appreciated to help me get to a “Hello World” with Caddy and FastCGI / Perl.

I installed Caddy using this tutorial

I am relatively new to Linux.

a. System environment:

Ubuntu 22.04
No Docker
Perl v5.34.0

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

} {
    encode gzip

3. The problem I’m having:

Initial setup of Perl FastCGI and example hello world script.

4. Error messages and/or full log output:

5. What I already tried:

I placed a simple CGI script using FastCGI format into the root web server directory. I simply displayed the text.


use strict;
use CGI::Fast;

my $count = 0;
while (my $q = CGI::Fast->new) {
print(“Content-Type: text/plain\n\n”);
print("Process ID: $$; Count is: " . ++$count);

6. Links to relevant resources:

Hi Robert, welcome.

Just to be clear, FastCGI is different from CGI: you won’t have a lot of success using FastCGI without a FastCGI responder to run your app. (Like how PHP has php-fpm.)

But you can use the fastcgi transport easily enough without PHP-specific settings:

reverse_proxy backend:1234 {
    transport fastcgi

You will want to change backend:1234 to whatever your FastCGI responder is listening on. And you may need to add some settings within a new block after transport fastcgi. But that’s the basic idea.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.