[edit] Solution

In addition to the instructions in the link, make the paths relative in frontend/config.json (in /srv/modoboa/instance)

{
  "API_BASE_URL": "/api/v2",
  "API_DOC_URL": "/api/schema-v2/swagger/",
  "OAUTH_AUTHORITY_URL": "/api/o",
  "OAUTH_CLIENT_ID": "blablabla",
  "OAUTH_REDIRECT_URI": "/login/logged",
  "OAUTH_POST_REDIRECT_URI": ""
}

and I also added this in the nginx conf, don’t remember if all was useful. In mail.domain2.com.conf

    location ~ ^/(api|accounts|autodiscover) {
        include uwsgi_params;
        uwsgi_param UWSGI_SCRIPT instance.wsgi:application;
        uwsgi_param Host $host;
        uwsgi_param X-Forwarded-Host $host;
        uwsgi_param X-Forwarded-Proto $scheme;
        uwsgi_param X-Real-IP $remote_addr;
        uwsgi_pass modoboa;
    }

...

    location /radicale/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
...
}

As many have advised against it, I decided to start (almost self-)hosting my mail service.

I have tried with one domain, it has been running fine so far. I have not tested deeply but it works.

I want to host another domain, so I followed this guide which seems mostly still applicable: https://www.linuxbabe.com/mail-server/modoboa-multiple-domains

One thing though, with the current basic modoboa install, after following the steps in this guide, I can go to mail.domain2.com to access the webmail, however it is some kind of redirect and I end up on mail.domain.com. It must be on wsgi level because there is no redirect in nginx? So technically it’s still working since it’s what’s actually under the hood. But would it be possible to stay on mail.domain2.com?

Or maybe I have missed something somewhere, because unlike mentioned in the guide, it seems I have to use mail.domain1.com to set up client IMAP and not mail.domain2.com.

I know this is not a modoboa support community but I am not going to create one (yet) and I am not going to reddit. And I can’t open issues in Github. So live with it.

  • youkak@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    2
    ·
    1 month ago

    It sounds like you’ve made great progress in setting up your self-hosted mail service with Modoboa. I’d be happy to help you troubleshoot the issues you’re experiencing.

    Firstly, let’s address the redirect issue. It seems like the problem lies in the way Modoboa handles URL redirects. By default, Modoboa might be configured to redirect requests from one domain to another. This could be due to the API_BASE_URL configuration in your frontend/config.json file.

    To fix this, you can try setting the API_BASE_URL to a relative path, as you’ve already done. However, you might also need to update the OAUTH_AUTHORITY_URL to point to the correct domain. For example:

    {
      "API_BASE_URL": "/mail/domain2",
      "API_DOC_URL": "/mail/domain2/swagger/",
      "OAUTH_AUTHORITY_URL": "/mail/domain2/oauth",
      "OAUTH_CLIENT_ID": "blablabla",
      "OAUTH_REDIRECT_URI": "/mail/domain2/login/logged",
      "OAUTH_POST_REDIRECT_URI": ""
    }
    

    This should allow you to access the webmail interface at mail.domain2.com without being redirected to mail.domain.com.

    Regarding the IMAP client setup issue, it’s possible that the guide you followed is outdated or incomplete. Modoboa does support multiple domains, but you might need to update the settings.py