Caddy: Fastcgi for Caddy v2

Created on 23 Aug 2019  路  5Comments  路  Source: caddyserver/caddy

1. What would you like to have changed?

I would really like Caddy v2 to be able to send fastcgi scripts to handlers via fastcgi interface, just like Caddy v1.
Hence fastcgi implementation would be awesome.

2. Why is this feature a useful, necessary, and/or important addition to this project?

In order for Caddy v2 to become the go-to webserver for the GO community, in my opinion being able to host sites based on cgi scripts is a must-have feature for Caddy v2.

3. What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

None at the moment, because Caddy v2 does not yet support third party modules/plugins.

4. Please link to any relevant issues, pull requests, or other discussions.

https://caddy.community/t/fastcgi-with-caddy-v2/6123

feature request

Most helpful comment

Funny you should ask, I heard through the grapevine that that's the next thing @mholt is about to look into implementing! 馃帀

All 5 comments

Funny you should ask, I heard through the grapevine that that's the next thing @mholt is about to look into implementing! 馃帀

A very rough but sort-of-working FastCGI implementation is in #2737. It probably won't work with some/most PHP apps yet but in theory it can at least do roundtrips with fastcgi backends. Feel free to give it a go! Just set the reverse_proxy's transport to use FastCGI:

"transport": {"protocol": "fastcgi"}

Other options are available but I haven't gotten around to fully integrating them yet. Still, it's sort-of usable.

This is now working in #2737. Caddyfile integration is also there, but I want to add a shortcut for PHP apps so that the necessary rewrites and matchers for PHP to work are hidden, since that'll be very common. That'll probably come in a separate PR.

Awesome work!

Though when I build caddy v2 from v2 branch, I get the following error:

$ git clone -b v2 "https://github.com/caddyserver/caddy.git" v2caddy
Klone nach 'v2caddy' ...
remote: Enumerating objects: 18467, done.
remote: Total 18467 (delta 0), reused 0 (delta 0), pack-reused 18467
Empfange Objekte: 100% (18467/18467), 10.97 MiB | 5.45 MiB/s, Fertig.
L枚se Unterschiede auf: 100% (11272/11272), Fertig.

$ cd v2caddy/cmd/caddy/

$ ls
main.go

$ go build
# github.com/caddyserver/caddy/v2/modules/caddyhttp
../../modules/caddyhttp/server.go:190:20: undefined: caddy.ParseListenAddr

$ ls
main.go
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hnrk/.cache/go-build"
GOENV="/home/hnrk/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hnrk/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/hnrk/go1.13/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/hnrk/go1.13/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/etc/buildv2caddy/v2caddy/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build194970707=/tmp/go-build -gno-record-gcc-switches"

I also cleared the modules and pkg folder for Caddy v2 to redownload the modules, still the same issue.

@Henrocker Oops, fixed; thanks. Guess my editor's Go plugin still isn't up to snuff with modules yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mschneider82 picture mschneider82  路  3Comments

jgsqware picture jgsqware  路  3Comments

crvv picture crvv  路  3Comments

wayneashleyberry picture wayneashleyberry  路  3Comments

ericmdantas picture ericmdantas  路  3Comments