ODK Central - Changing domain names

Hi,

I have setup ODK Central on a certain domain (e.g. abc.com), and now want the same installation to work under another domain (e.g. xyz.com) [Please note that it is a migration, and not an effort to run both in parallel at the same time]. The server and IP address remains the same, so I just need to map the old IP address to the new sub-domain. What changes do I need to make in Central configuration? Is it just the change in .env file, to update to new URL? I assume I would have to do 'docker-compose build' as well afterwards? Would it hurt the existing forms data present in the Central? Any other changes needed?

I see a relevant link here (Can I change my domain name after Installing ODK Central?) but no confirmed answer. Did you try it and it worked fine @iamnarendrasingh?

Thanks,
Saad

Hey @Saad ,

I hope you are well and safe. I follow the below steps:

  1. Login into Cloud(Digital Ocean/AmazonEC2) and open .env file
  2. Open the registered domain DNS page with IP address information.
  3. Update .env file accordingly.
  4. Run the "docker-compose build" command and restart docker.
  5. In my case it took nearby 5-10 minutes to reflect on the new server.

Best,
@iamnarendrasingh

1 Like

Any data loss risk possible to happen?

I haven't verified recently, but everything in Enketo is bound to the domain, so I'm pretty sure public access links (and maybe even previews) will not work if you rebuild with a new domain.

It's possible that re-uploading a new version of each form with an incremented version number will fix it, but I haven't tested that workaround.

Worst case scenario, you'll need to go into the Redis DBs at central_enketo_redis_main_1 and central_enketo_redis_cache_1 and manually replace the old domain name with the new. Not straightforward to do, but doable.

Try this on a backup first.

Hey, @Saad as @yanokwa mentioned only public access links and script which I created to download raw data from the server affected. And I rebuild them in my case I did not have any data loss on my side. One more thing, I am not using any other database server for maintaining the datasets.

Best,
@iamnarendrasingh

Hi,
so I guess that a single Central installation cannot be accessed and used using more than 1 domain name, correct?

thanks in advance.

Theoretically no. Central setup asks for domain name during installation and its also bound by SSL certificates. You 'may' setup a redirect from another domain, but the main domain will remain the same. You won't be able to replicate many things, especially the server address in the collect app associated with long form names.

You can have two domains pointed to the same install.

To do that, have example1.com and example2.com pointed to the same IP.

Then put example1.com in your ~/central/.env file.

SSL_TYPE=letsencrypt
DOMAIN=example1.com

Then in ~central/files/nginx/odk.conf.template, make this change in line 3.

- server_name ${CNAME};
+ server_name ${CNAME} example2.com;

I've only tried this with LetsEncrypt as an SSL type. Your mileage may vary with other types.

Thanks for the tip! I will try that and let you know how it went!