I found the nginx local conf was corrupted under /etc/nginx/conf.d/local.conf, the primary hostname did not show up properly.
skimming through web_update.py I was able to generate a valid conf file myself and replace it to enable admin panel access.
perhaps $PRIMARY_HOSTNAME is no longer correctly determined causing the file to be corrupt, and if my hostnames are corrupt and the nginx file is regenerated, I will lose access again. Any hints on how I best troubleshoot this?
Please note that until I decided to look into the cause, I had only used the control panels and www/default directory, so I do think there is a bug here somewhere…
EDIT: I believe the cause of the error was adding an A record to point box.mydomain.com to the ip of the digital ocean droplet, this removed box.mydomain.com as the primary hostname ?
EDIT: just adding the CNAME for mail.mydomain.com (toward the FQDN for box.mydomain.com. - notice trailing dot) and creating the www/default/webmail with redirecting index should have been enough to redirect all users that still went to mail.mydomain.com/webmail - I believe I was getting errors because of browser dns cache and should have cleared the cache before continuing with my reconfigurations.
I think the most important part is, if you set up mail in a box for box.mydomain.com, don’t add DNS A records for both mydomain.com and box.mydomain.com, even if the A record you add for box.mydomain.com points to the very ip of the MiaB, it seems that would cause the nginx config to miss out the primary host part redirecting to the python flask admin page. To recover from this, you’d need to modify the nginx config to re-add this part for the primary server https://github.com/mail-in-a-box/mailinabox/blob/master/conf/nginx-primaryonly.conf
on windows ipconfig /flushdns and firefox>history>clear history>only tick cache are your friends!