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

Hi, all, I’m trying to test this, but am having an issue, I may be understanding it incorrectly.

Per @Just4t’s instruction, I have www/cloud2.domain.com (cloud is already somewhere else, I’m thinking of moving) and this:

    <!DOCTYPE HTML>
    <html lang=“en-US”>
    <head>
    <meta charset=“UTF-8”>
    <meta http-equiv=“refresh” content=“1;url=https://mail.domain.com/cloud”>
    <script type=“text/javascript”>
    window.location.href = “https://mail.domain.com/cloud”
    </script>
    <title>Page Redirection</title>
    </head>
    <body>
    If you are not redirected automatically, follow this <a href=‘https://mail.domain.com/cloud’>link to /cloud</a>
    </body>
    </html>

My understanding is that if I type cloud2.domain.com it should redirect to the nextcloud link. But it just goes to the default “this is a mail-in-the-box” with failed ssl. Thoughts?

What do you have in the ‘Web’ page of the dashboard for that subdomain?

The failed certificate is because you need to provision the cert on the ‘TLS (SSL) Certificates’ page.

Ok I can fix the second bit, it’s been a bit since I touched it but I am wanting to move my home-based nextcloud to the vps so now I’m tinkering. What do you mean by the first bit?

You are following a 6-year old thread, so you might want to navigate in the MiaB dashboard to the page called ‘Web’ and see if the instructions there can help you.

OH I see, ok so I have to actually change it there, so now I have to wait until that record shows up, or is there a way to force refresh?

You should install the redirect index.html to the directory of the domain/subdomain you want to redirect. That domain/subdomain needs to have a DNS record and a cert (which it may, already).

Be default, MiaB assigns every domain the same index.html location, so to change it based on domain and subdomain, you need to click ‘Change’ next to the desired domain/subdomain in the dashboard ‘Web’ page and follow the instructions in the dialog box.

Then place your redirect file in the directory for the domain/subomain that you have just configured.

Ok I think I have it working, I must have misunderstood, I thought it would actually write the subdomain in the address bar.