[RESOLVED] box.mydomain.com/admin suddenly 404s

I’m using Digital Ocean - Ubuntu 14.04 with 1GB RAM, 30GB SSD created a droplet named “box.mydomain.com

worked fine initially, registrar nameservers point to ns1/ns2.box.mydomain.com and all other admin checks looked good (apart from self-signed cert and optional secure dns)

email and owncloud was working

However, I was having difficulty redirecting mail.mydomain.com to box.mydomain.com and pointing mydomain.com to the ip of the host running that website.

changes in custom DNS:

  • added A record for empty subdomain pointing to host ip - mydomain.com now came up correctly
  • added CNAME record for mail subdomain pointing to FQDN box.mydomain.com. - seemed to work
  • removed A record for empty subdomain pointing to host ip - I was having issues reaching box.mydomain.com on different machines after step 2
  • added A record for box subdomain pointing to digital ocean ip

mail.subdomain.com/mail seemed to be working

filesystem changes to redirect webmail to mail

  • created webmail subfolder with index.html which uses javascript to set window.location to box.mydomain.com/mail
  • copied index.html from webmail subfolder to default folder

suddenly admin 404s (maybe I accidentally deleted it? I didn’t use rm, only cp… so I’m suprised…)

how do I set up the admin control panel again?

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!