Can't get caddy to work with dynamic tls

I’m trying to get caddy to work with dynamic tls. My current setup is with apache and lets encrypt.

I have a crm that allows us to add a records for custom domains.

The CRM instructions state to change ports.conf to 8081.

Then caddy file is:

Caddyfile

Global options block

{
on_demand_tls {
ask http://localhost:8081/api/caddy_domain_check
interval 2m
burst 5
}
}

HTTPS configuration for your domain

:443 {
tls mail@domain.com {
on_demand
}
encode gzip
# Reverse proxy to Apache (on port 8081, serving /var/www/html)
reverse_proxy localhost:8081 {
header_up X-Real-IP {http.reverse-proxy.upstream.address}
}
}

and then Apache 000-default.conf is

<VirtualHost *:8081>
ServerAdmin webmaster@localhost
ServerName domain.com
ServerAlias *.domain.com *
DocumentRoot /var/www/html

<Directory /var/www/html/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<IfModule mod_dir.c>
    DirectoryIndex index.php index.pl index.cgi index.html index.xhtml
</IfModule>

I’ve set this up but it doesn’t work.

Do I need to disable my 000-default-le-ssl.conf file?

I do need apache at all?

Can you be more specific about the experience? What does “doesn’t work” means? What happens? What’s in your logs?

Probably yes, if you expect Caddy to handle HTTPS.

That depends on how you’re using Apache. Is it merely a file server? Or are you using mod_php?

1 Like

I disabled apache and found that I need to enable php-fpm. I can get one domain to work now but I can’t get all domains to work. Here is my Caddyfile

  • {
    root * /var/www/html
    php_fastcgi unix//run/php/php8.3-fpm.sock
    file_server
    }

That dot is a star.

A star as the site address is invalid. Please review the Caddyfile Concepts page.

1 Like

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