Access Mailbox From A Subdomain

I am not sure if this is possible. But I think that would be great, if I can access my mailbox by typing:

mail.domain.com which leads to box.domain.com/mail

Especially for my familiy would that be a great feature, they are all not that techie and I want it to be as easy as possible for them to acces their email accounts. Actually that should just be some lines in the nginx config isn’t it? Cause as far as I know, that redirect is not doable with DNS. Am I wrong?

Dont know about nginx config.
But quick n dirty i would create the subdomain mail.domain.com and
place a index.html file in the static webhosting directory that redirects
the user to box.domain.com/mail.

@nate as @ibib said, the best option knowing we can’t use a .htaccess file (not apache installed) and the option of customizing /etc/nginx/conf.d/local.conf will force us to re-edit it each time we’ll upgrade MiaB then, the best way I see to achieve this is by using a custom /home/user-data/www/default/index.html file as follows:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=https://box.yourdomain.com/mail">
        <script type="text/javascript">
            window.location.href = "https://box.yourdomain.com/mail"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        If you are not redirected automatically, follow this <a href='https://box.yourdomain.com/mail'>link to /mail</a>
    </body>
</html>
  • Edit it by replacing box.yourdomain.com by your own server_name.

  • Note we are using a meta, and a javascript redirections plus a link inside the index.html static file that should make the desired redirection to work well within any browser.

Hope this helps!

3 Likes

Wow, that works like a charm. Thank you so much - perfect, at least for me! :wink:

try check this one. Best way to redirect root page to /mail?

@aa6my : Yes, works too! but as said /etc/nginx/conf.d/local.conf file will be reset to default after each Miab update or upgrade :stuck_out_tongue_winking_eye:

1 Like

Jep, the solution from @just4t just worked in a matter of seconds. And that I don’t have to care, when an update comes is even bber. :wink:

I have tried the @just4t solution and it is not working on my end. Is there a new or alternative way to achieve the same?

There shouldn’t be. Paste the code that you used here.

This is the solution I have tried Access Mailbox From A Subdomain

Yes, and as others have noted, that works fine … but yours doesn’t which is why I asked you to “paste the code that you used here”.

Of course, if you want to keep your domain name private, you can PM instead.

1 Like

You can actually create a custom.yaml file in /home/user-data/www/

mydomain:
  redirects:
    ^/$: $scheme://mydomain/mail

Then you need to go into mailinabox/management and do sudo ./dns_update.py to refresh the dns

This solution does not get overwritten during upgrades.

1 Like

Thank you this worked