How to up multiple site

Hi guys need some help I am using frankenphp and it uses the caddy , my problem I am deploying my 2 image to the digital ocean, but the problem is only 1 container will up because it conflict the ports 80 and 443

My 2 app has it’s own dockerfile, after I build this I push this to docker hub and pull to my server digital ocean, I only have 1 docker compose

  srv1:
    container_name: containerimage1
   
    image: myusername/myimage1:latest
   
    ports:
        - "80:80" # HTTP
        - "443:443" # HTTPS
        - "443:443/udp" # HTTP/3
      
    volumes:
        - caddy_data:/data
        - caddy_config:/config
    
    entrypoint: php artisan octane:frankenphp --max-requests=1 --host=api.my-real-domain.online --port=443  --admin-port=2019 --https
    environment:
        - SERVER_NAME=api.my-real-domain.online


  srv2:
    container_name: containerimage2
   
    image: myusername/myimage2:latest
   
    ports:
        - "80:80" # HTTP
        - "443:443" # HTTPS
        - "443:443/udp" # HTTP/3
      
    volumes:
        - caddy_data:/data
        - caddy_config:/config
    
    entrypoint: php artisan octane:frankenphp --max-requests=1 --host=my-real-domain.online --port=443  --admin-port=2019 --https
    environment:
        - SERVER_NAME=my-real-domain.online

It tried also to change the ports to my srv2 but it will not up because of the certificate ?

 WARN  automatic HTTP->HTTPS redirects are disabled
 
    ERROR  challenge failed
  ERROR  validating authorization

   ERROR  challenge failed

   ERROR  validating authorization
 
    ERROR  could not get certificate from issuer

How can I up my 2 container so that I can access my site

https://my-real-domain.online
and
https://api.my-real-domain.online

please let me know if you need some other info ?

Thank you in advance

I think you’ve been helped on Discord… but TLDR, two options:

  • Put a third Caddy instance in front which proxies (over HTTP) to either container based on the domain name using site blocks, and this third one is the only one which binds to ports 80/443

  • Combine both containers into one, and serve both PHP apps from the same container. Mount the PHP files into the container as separate volumes.

1 Like

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