Serve index.php with caddy on Docker

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

dockerized caddy

a. System environment:

Armbian 21.02.1 Buster with Linux 5.10.12-rockchip64

Docker 20.10.3 (API: 1.41)

b. Command:

 	caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

c. Service/unit/compose file:


d. My complete Caddyfile or JSON config:

#MAIN
mywebsite.me {
        root * /srv/mywebsite
        file_server
	encode gzip
}

#Gazebo
gazebo.mywebsite.me {
	root * /srv/gazebo
	file_server
	encode gzip
}

#BLOG
blog.mywebsite.me: {
    root * /srv/blog
    php_fastcgi 127.0.0.1:9000
    file_server
}

3. The problem I’m having:

I try to access to my index.php file in /srv/blog to setup a CMS

4. Error messages and/or full log output:

5. What I already tried:

Tried to use

php_fastcgi unix//run/php/php7.4-fpm.sock and 

and

php_fastcgi 127.0.0.1:9000

either one does not work… thank you for taking the time to help me. i am a neophyte, please excuse my ignorance.

6. Links to relevant resources:

Please upgrade to v2.4.3, there’s been some important fixes since your version.

You seem to have an extra colon in there. Maybe that’s the problem.

What’s your evidence? What’s in your logs? What do you see when you make the request with curl -v? Just saying “does not work” is not useful. We need specifics.

Where do you have PHP running? If you’re running Caddy in Docker, then you must have PHP running in another container? What Docker commands did you run, or what’s your docker-compose.yml file?

Hi, thank you for your answer and sorry for my delay…

Where do you have PHP running? If you’re running Caddy in Docker, then you must have PHP running in another container? What Docker commands did you run, or what’s your docker-compose.yml file?

I thought php was already in the Caddy container.

If I understand correctly, I have to create another PHP container and make the links between caddy and php?
Thank you

Yes. You’ll need a PHP-FPM variant. See Docker Hub

You can look for guides on setting up PHP in Docker for nginx. The process is exactly the same for Caddy, with just Caddy swapped in to replace nginx.

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