Multiple domains on single docker app

I have a working docker container with a secure domain and would like to add several more domains pointing to the same app.

I’m not seeing how to do this in Wappler, nor the portainer and traefik dashboards.

Anybody tackle this yet?

1 Like

I manually changed part of the docker-compose file (.wappler/targets/TARGETNAME) with some extra traefik settings in the labels property:

       traefik.http.routers.sites__TARGETNAME_web-secure.rule=Host(`DOMAIN1`) || Host(`DOMAIN2`)  || Host(`DOMAIN3`)
 - traefik.http.routers.sites__aws_docker_clubsites_web-secure.tls=true
     - >-
       traefik.http.routers.sites__aws_docker_clubsites_web-secure.tls.certresolver=leresolver
     - >-
       traefik.http.services.sites__aws_docker_clubsites_web.loadbalancer.server.port=80
     - traefik.docker.network=wappler-compose_proxy
     - >-
       traefik.http.routers.sites__aws_docker_clubsites_www_web-secure.entrypoints=websecure
     - >-
       traefik.http.routers.sites__aws_docker_clubsites_www_web-secure.rule=Host(`DOMAIN1`) || Host(`DOMAIN2`)  || Host(`DOMAIN3`)
     - traefik.http.routers.sites__aws_docker_clubsites_www_web-secure.tls=true
     - >-
       traefik.http.routers.sites__aws_docker_clubsites_www_web-secure.tls.certresolver=leresolver
       traefik.http.routers.sites__aws-docker-clubsites_web-secure.tls.domains.main=`DOMAIN1`
       traefik.http.routers.sites__aws-docker-clubsites_web-secure.tls.domains.sans=`DOMAIN2`
       traefik.http.routers.sites__aws-docker-clubsites_web-secure.tls.domains.sans=`DOMAIN3`

It was a while ago and things may have changed in Wappler that might now overwrite changes but it worked for me

1 Like

Do you want different domains to point to the exact same app? There is not much sense to it and actually not allowed by Google and you can get penalized by offering the same content under different domains.

Maybe you mean that you want a wild card name in front of the domain?

@George is this a safe method?

Actually on this, you are completely mistaken. It is very common to allow customers to use their own domain so they can provide a branded experience to their users.

The content is all dynamic and well within Google’s policies. And in most cases, the applications that do this are behind a login so will not be indexed.

Wildcard domains will also be needed, but not as a replacement for using fqdn’s from external sources.

I’ve done all of this outside of docker and it is working quite well. The current client though would like to do this using docker.

1 Like

Traefik was built with containers in mind so it can dynamically change the configuration without restarting and generate certificates on the fly. It’s a good option for white labeling the domains.

1 Like

Right, but how? I don’t see anything in the dashboard to add domains. I also tried to just point a domain in to see if it would trigger a cert for any traffic presented but that didn’t work either.

You are only adding domains for certificates and routing (that it accepts multiple domains rather than the single one added by default within Wappler) - there’s only 3 lines from the original config changed (adding the domains and registering them as SANs). I don’t see how any safety could be compromised. All you need to do is keep a copy of the config you can copy/paste back in IF it gets overwritten at any point.

Everything ends up in the same place. What you might struggle with is dynamic Cookie domains if you use them - I’m sure there’s a way of overcoming that, though.

I haven’t used traefik but I am assuming the CLI will do that.

If you are using node you can control the cli with exec() or spawn()

Unless you are planning on adding the configuration by hand of course. I don’t know how big your app is.

Thanks Ben. No concerns from me on your solution (which I will try soon). Just want to make sure Wappler does not overwrite.

Thanks @bpj for a working solution.

For a newly created docker container, the modifications were:

        traefik.http.routers.docker-cert-test__stg_web.rule=Host(`domain1.com`, `domain2.com`)
      - >-
        traefik.http.routers.docker-cert-test__stg_web-secure.entrypoints=websecure
      - >-
        traefik.http.routers.docker-cert-test__stg_web-secure.rule=Host(`domain1.com`, `domain2.com`)

Initial tests have this working perfectly after re-deploying the container. Naturally Wappler does rewrite this file if changes are made to the target, so care will have to be taken to re-modify with the added domains when making changes to the target, but that’s not a huge ask. Re-deploys work fine.

Thanks guys.

4 Likes

Thanks for asking this is one! I will eventually have to deal with this wanting to offer an app white label solution using docker.

1 Like