1. Caddy version (caddy version
):
v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
2. How I run Caddy:
a. System environment:
Ubuntu 20.04, docker, docker-compose
b. Command:
docker-compose up -d
c. Service/unit/compose file:
version: '3'
services:
caddy:
image: caddy
container_name: caddy
restart: unless-stopped
volumes:
- ./caddy/data:/data
- ./caddy/config:/config
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ~/www:/www
ports:
- 80:80
- 443:443
php:
image: php:7.4-fpm-alpine
container_name: php
restart: unless-stopped
working_dir: /www
volumes:
- ~/www:/www
d. My complete Caddyfile or JSON config:
:80 {
root * /www
encode gzip
php_fastcgi php:9000
file_server
try_files {path}/index.html
}
3. The problem I’m having:
I have the following files at ~/www
: index.html
and index.php
.
Also in subfolder ~/www/test.com
I have a second index.html
and a photo01.JPG
file:
<html>
<body>
<h2>Test page</h2>
<img src="photo01.JPG">
</body>
</html>
When I try http://serveraddress
I can see the file index.html
. If I remove this file, the index.php
is served ok.
But if I try http://serveraddress/test.com
I can see the “Test page” text but not the image.
If I try http://serveraddress/test.com/
(with the slash) I can see both the text and image.
How can the trailing / can be added to the URL?
I know that the solution must be very simple but I am a newbie in caddy and still learning.