Multi Domain And Laravel Error Databases Connection

1. The problem I’m having:

I use multi domain with same server, with same IP and one Caddy. example i call the domain is https://site1 and https://site2. in my site i use laravel, its success open two site that, but the problem is in database connection, when on first open is site1 then success connected to site1database, but when i open site2, database still connected to site1database. in other case, i restart the caddy, i first open site2, database connected to site2, but when i open site1 database still in databasesite2. soo, look like caddy get wrong get information the .env or laravel config.

2. Error messages and/or full log output:

This error when i 1st open site1 then site2
Site1 Database : site1db with table tablesite1
Site2 Database : site2db with table tablesite2

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'site2db.tableinsite2' doesn't exist

3. Caddy version:

v2.9.1

4. How I installed and ran Caddy:

a. System environment:

Ubuntu Server 22.04

b. Command:

frankenphp run --config /etc/caddy/Caddyfile

c. Service/unit/compose file:

[program:site1]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/bin/frankenphp run --config /etc/caddy/Caddyfile
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/supervisor/site1.log

d. My complete Caddy config:

{
        frankenphp {
                worker /var/www/site1/public/frankenphp-worker.php
                worker /var/www/site2/public/frankenphp-worker.php
        }
}

https://site1 {
        root * /var/www/site1/public/
        encode zstd br gzip
        tls /home/servername/ssl/site1/fullchain.pem /home/servername/ssl/site1/site.key
        php_server
}

https://site2 {
        root * /var/www/site2/public/
        encode zstd br gzip
        tls /home/servername/ssl/site2/fullchain.pem /home/servername/ssl/site2/site.key
        php_server
}

5. Links to relevant resources:

This is more of a FrankenPHP question than Caddy. Try posting the question on the FrankenPHP discussion on GitHub.

1 Like