1. The problem I’m having:
I’m trying to run two sites on the same caddy server : domain01.com
and subdomain.domain01.com
I’ve tested my DNS configuration separately and it works properly for both domain and subdomain.
Caddy is run by the caddy user of the caddy group.
The directories of both websites are configured exactly the same, including access, reader, write and execute permissions.
2. Error messages and/or full log output:
The first site, domain01.com
, works properly both in HTML and PHP.
The second one, submdomain.domain01.com
, return 403 for the index.html file et 404 for info.php
3. Caddy version: v2.7.6
4. How I installed and ran Caddy:
I followed the official Rocky Linux tutorial for caddy installation : Caddy Web Server - Documentation
a. System environment:
Rocky Linux 9.3
b. Command:
sudo systemctl start caddy
c. Service/unit/compose file:
d. My complete Caddy config:
# The Caddyfile is an easy way to configure your Caddy web server.
#
# https://caddyserver.com/docs/caddyfile
# The configuration below serves a welcome page over HTTP on port 80. To use
# your own domain name with automatic HTTPS, ensure your A/AAAA DNS record is
# pointing to this machine's public IP, then replace `http://` with your domain
# name. Refer to the documentation for full instructions on the address
# specification.
#
# https://caddyserver.com/docs/caddyfile/concepts#addresses
# Domaine domain01.com
domain01.com {
# Set this path to your site's directory.
root * /srv/www/domain01.com/htdocs
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
php_fastcgi 127.0.0.1:9000
# Refer to the directive documentation for more options.
# https://caddyserver.com/docs/caddyfile/directives
}
# Redirection www vers domain01.com nu
www.domain01.com {
redir https://domain01.com{uri}
}
# domaine subdomain.domain01.com
subdomain.domain01.com {
root * /srv/www/subdomain.domain01.com/htdocs
file_server
php_fastcgi 127.0.0.1:9000
log {
output file /var/log/caddy/subdomain.domain01.log
}
}
# As an alternative to editing the above site block, you can add your own site
# block files in the Caddyfile.d directory, and they will be included as long
# as they use the .caddyfile extension.
# import Caddyfile.d/*.caddyfile