What is process of changing the domain name of a deployed instance?


Are there guidelines we can follow to change the domain name of a deployed instance?


#it4life @Rodolphe

We have changed the domain name and server email of our commcare application by doing the following:

  • modify proxy.yml file ($COMMCARE_CLOUD_ENVIRONMENTS/< env >/proxy.yml)
    change SITE_HOST parameter with new domain name.
  • modify public.yml file ($COMMCARE_CLOUD_ENVIRONMENTS/< env >/public.yml)
    change server_email, default_from_email, root_email with our new email;
    also change internal_domain_name and domain
  • Update configuration with commcare-cloud < env > update-config
  • Set up valid SSL certificates with :
    • commcare-cloud < env > ansible-playbook letsencrypt_cert.yml --skip-check
    • commcare-cloud < env > ansible-playbook deploy_proxy.yml --skip-check

After all this, the new domain name is working and has a valid SSL certificate, but we have some issues.

  1. When we are on the new domain name and we go to Admin > View all for example, we are redirected to the old domain name despite the fact that the highlighting url is from the new domain name
  2. The old domain name still works when we use it directly in the url search bar.

Does we miss something to properly change the domain name ?
Sound like some cache issue ?

Thanks for help.

You probably also need to update the Django site which can be done via the Django admin panel:

https://[your domain]/admin/sites/site/

or a Django shell:

from django.contrib.sites.models import Site
site = Site.objects.all()[0]
print(site)  # confirm it's still references the old domain
site.domain = 'new domain'
1 Like

Thanks @Simon_Kelly. We had already updated the site via the Django Admin panel.

There's also this issue where the link generated for the QR code of an app is still using the old domain name (si-imyeta.gret.org), while the url of the page itself is using the new one (commcare.gret.org).

I was wondering if we had to update additional config files or execute another ansible task to propagate the domain name change further?


1 Like

Also curious if, as @Rodolphe mentioned, there is a cache that must be cleared?

1 Like

Thanks @Simon_Kelly.

New domain name is print when i use django shell.

I don't think clearing the cache would make any difference.

The app URLs are generated based on the BASE_ADDRESS setting so you could check that to make sure it's correct. You should also make sure you haven't configured a custom base URL for the app (in advanced app settings).

Thanks @Simon_Kelly.

The BASE_ADDRESS is good. We did not activate the feature flag that allows to change the base URL, so it's unchanged.

Any other ideas?

@guillaume you may need to make a new build in order to update the URL in the build artifacts.

Also, doing this sort of transition with active users can be a bit tricky, especially if rolling out a new app version takes time. I'd recommend reviewing these docs for ideas, particularly Section 1, "Switch mobile devices to a proxy URL"


Most of that document shouldn't be relevant to this use-case, but part of it deals with managing a domain name transition with active mobile workers who already have the app deployed. Setting a custom base URL might be helpful, as would using the DATA_MIGRATION to temporarily bring down mobile endpoints.

1 Like