1. The problem I’m having:
Hi there, I’m new to web development and need some help with setting up a server but first I need to get it running locally.
I’m trying to get one caddy container as reverse proxy that serves multiple PHP applications in their own seperated containers using docker-compose.yml
This is my idea before trying different and simple alternative.
- Caddy Server - Image:
caddy:2.7.6-alpine
- PHP RSVP App - Image:
dunglas/frankenphp
← This is also based off caddy image - and many more PHP app that will be added later.
I can curl PHP RSVP App
from Caddy Server
without any problem. But when I tried to access using my browser it returns an empty page.
2. Error messages and/or full log output:
curl response from Caddy Server - SUCCESS
/srv # curl -v rsvp
* Host rsvp:80 was resolved.
* IPv6: (none)
* IPv4: 172.29.0.3
* Trying 172.29.0.3:80...
* Connected to rsvp (172.29.0.3) port 80
> GET / HTTP/1.1
> Host: rsvp
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Server: Caddy
< X-Powered-By: PHP/8.3.3
< Date: Fri, 08 Mar 2024 05:53:52 GMT
< Content-Length: 15
<
Hello from PHP
* Connection #0 to host rsvp left intact
curl response from my Mac - FAIL
note: I have set /etc/hosts
to point rsvp.local to 127.0.01
curl -v rsvp.local
* Trying 127.0.0.1:80...
* Connected to rsvp.local (127.0.0.1) port 80
> GET / HTTP/1.1
> Host: rsvp.local
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Fri, 08 Mar 2024 05:54:56 GMT
< Content-Length: 0
<
* Connection #0 to host rsvp.local left intact
3. Caddy version:
- Revere proxy -
caddy:2.7.6-alpine
- PHP App -
dunglas/frankenphp
4. How I installed and ran Caddy:
a. System environment:
Running on 2017 Intel Macbook Pro - Docker v4.28.0
My mac host’s etc/hosts
has been setup to point rsvp.local
to 127.0.0.1
b. Command:
docker compose up -d --build
c. Service/unit/compose file:
services:
caddy:
image: caddy:2.7.6-alpine
restart: always
ports:
- "80:80"
# - "443:443"
# - "443:443/udp"
volumes:
- ./caddy/data:/data
- ./caddy/config:/config
- ./caddy/caddyfile/:/etc/caddy/
networks:
- backend
rsvp:
container_name: rsvp
image: dunglas/frankenphp
restart: always
ports:
- "81:80"
# - "444:443"
# - "444:443/udp"
volumes:
- ./app:/app
environment:
- SERVER_NAME=rsvp:80
networks:
- backend
networks:
backend:
driver: bridge
d. My complete Caddy config:
Caddyfile
rsvp.local:80 {
reverse_proxy rsvp
}
The ./app/public/index.php contains
<?php
echo "Hello from PHP";
echo PHP_EOL;