R
renaud

  • Dec 5, 2024
  • Joined Sep 5, 2024
  • 4 discussions
  • 15 posts
  • 0 best answers
  • Post posted... wait what?
  • Musing with mailcow since september and more or less it is working, but all these little settings are killing me: I learn the hard way, and it is really the hard way.

    Well, I use grafana for observabilty and I observe everthing. I wrote some code to scrap the mailcow api, and it is fine, now I observe the mailboxes, the queue, the quarantine and I am able to add some alerts, in case…

    Today I would like to observe rspamd. In mailcow settings it is possible to add a password to the app and then manage rspamd : http://mymailcow.random.io:40080/rspamd/

    But I want to get access to the rsqpamd API. When I use the stat endpoint : http://mymailcow.random.io:40080/rspamd/stat

    all I get is this json :

    {
    "error": "Unauthorized"
    }

    If I curl it:

     curl -u "admin:mypassword" http://localhost:40080/rspamd/stat
    {"error":"Unauthorized"}

    So, is there any mailcow guru here that can help me to gain access to the rspamd api?

    Thanks in advance, rr

  • DocFraggle

    No idea, my admin system done this for me, the port is not open to the whole internet but managed to accept one IP adsress.

    What I want to achieve : use a Foreign Data Wrapper with Postgres.
    Why :

    • I manage observability and use Grafana. I have a huge amount of servers and database to manage. With FDW I can have only one datasource in Grafana to grab information from hundreds of databases
    • Having access to the databases in mailcow I can compare the number of mailboxes in the Prod with the replication. I can compare the number of messages, get some information about the satus of thez syncjobs
      With Grafana I can build alerts if something seems wrong, ie syncjob fail, if a mailbox is near the quota etc…
  • Well, I don’t know if it can help, but here is what we have done.

    • first I installed dbeaver in a container: this is cloudbeaver, to try to connect on the same computer, to the MariaDB database, to be sure at least this first step was working (and it was)
    • then we defined this env var “MAILCOW_REPLICA_IP” withe the IP of the computer we want to connect. We done this for containers netfilter & dovecot
    • finally we defined MYSQL_ROOT_HOST=% for the mysql container

    Then on my postgresql database I defined a Foreign Data Wrapper to connect the MariaDB database. It was a bit difficult because of few definitions but if you need I can explain what I have done.

  • Morning lords of Mailcow-Dockerized,

    I plan to have a kind of “replication” server from A to B using this way:

    • copy the MySQL “mailbox” table from A to B
    • create syncjobs on B to synchronize messages received on A to B server

    So my question:
    1 - do you think this solution could work ?
    2 - is there any smarter and more elegant way to do it?

    Enjoy your coffee!

    Ha and I nee also to copy quota2 at least.

  • esackbauer

    Searched which FAQ, not found. Is there any link you can provide? Thanks in advance.

    • DocFraggle I, it is a question of course we thought about.

      Right now we have:

      • some functions using the api. The goal is to generate from our own tables the mailboxes and the syncjobs: we executed these functions on 3 different servers and it saved us a lot of time. Next version of mailcow I will check the api to confirm it is ok, or need changes
      • some functions using the api, from postgres, to present the result as tables (you know, relations between tables is convenient), but I don’t want to use them because
      • with foreign data wrapper in postgres I can request “directly” MySQL database. If the tables change, I drop the schema and import it again : 2 sql commands.
    • Yes, thanks for the link, I will investigate !
      There some questions remaining for me:

      • why the syncjobs are not executed in parallel
      • where is the list, it takes some times to start, the log is not available during the processes but at the end
      • I would like to execute / interrupt by myself

      I want to add something. At the moment you convert the data from api into tables, you can organize relations and history. What was the status of this point 7 days ago. You don’t have this information with the API just offering a photo of the system right now.

      With history you can draw tendencies.

    • DocFraggle

      Yes, I already wrote some functions for API requests but for Grafana I prefer to use a unique postgres datasource instead of hundreds datasources.

    • The problem is not the remote access but the access on the “localhost”

      Host2: connecting and login on host2 [localhost] port [143] with user [mat@xxx.org*qsdqsd@mailcow.local]
      Host2 failure: can not open imap connection on host2 

      About Grafana, I am managing observability for the company and I want one pair of googles for everything.

      This is why:

      • first I coded api get to grab information from api, inside Postgres with plpython
      • I also coded api put to create automatically (from tables) the mailboxes and the syncjobs
      • then managed to have a Foreign Data Wrapper from MySQL to Postgres in order to have only one datasource for Grafana. I have around 200 FDW in my Postgres and it simplifies ² all the tasks
      • I got few difficulties to import the MySQL schema but it is doable.

      Next I plan to add some alarms to inform us about quotas.

      Maybe mailcow dockerized team should think about grafana in the package.

      • I have 110 mailboxes and 110 syncjobs defined. There is 4 syncjobs not working:

        • 3 of them have this status EXIT_CONNECTION_FAILURE_HOST2 and share the same problem in the log “Host2: sslcheck did not detected open ssl port 993. Will use standard 143 port.”
        • the last one has no exit status

        The strange thing is the fact that it is working for the other mailbaoxes, and for these one, some messages are imported but it fails, restart, reimport some messages, fail again and restart.

      • It did not.
        We finally gain some success, I will explain later.

      • Thanks for the answer, but how to change this? How to connect the database from another on the network.

      • DocFraggle Ha yes, you were right… I am currently in China and behind the Great Numeric Wall… I use tailscale as a VPN, if it is not installed, I connot do even a git clone…
        On a distant computer located in the European Cloud, it was just an affair of 15 minutes. Thanks a lot for your help!

      • DocFraggle
        1 - The link for the youtube is random one picked up, more or lesse I’ve use the same way with a fresh docker and docker compose.
        2 - Changed the parameters because the machine is already using some ports for other containers.

        I’ve just done inside the sogo container a test to connect it to dovecot

         nc -zv 172.42.1.250 143
        mailcowdockerized-dovecot-mailcow-1.mailcowdockerized_mailcow-network [172.42.1.250] 143 (?) : Connection refused

        So it seems to me sogo cannot connect dovecot…

      • I am sorry to come and probably ask for a stupid point. I am not particulary stupid but I guess I lack some basis.

        I’ve installed mailcow-dockerized for a test in 3 different machines and I end each time with the same thing.

        After doing the same thing for example like here “youtube.com Icon - YouTube

        I have the message in sogo “Aucune Boîte sélectionnée” or translated in english “No mailbox selected”.

        I have:

        • done git clone for the last version,
        • use docker 26 and 27 (depending on the computers)
        • configured the mailcow.conf with
          HTTP_PORT=30080
          HTTPS_PORT=30443
          SMTP_PORT=30025
          IPV4_NETWORK=172.42.1
          Installed,
          changed the admin passwor
          created a dmoain blabla.local and restarted
          created one mail address
          then launched sogo.
          With sogo I can log with the mail user parameter, can see the calendar can add some personnel addresses, but the mail icon only shows me “No mailbox selected”.

        At the moment I can see videos and doing the same steps, I think I missed a stupid little thing somewhere.

        I’ve spend a lot of time since the last days on this subject, I am tired and asking for some help. Thanks in advance.

        And I want to add I have this message from sogo

        Sep  5 08:56:44 c0dcc9496261 base=(null)
        Sep  5 08:56:44 c0dcc9496261 base-class=(null))
        Sep  5 08:56:44 c0dcc9496261 = <0x0x557c0624ae60[NGImap4Client]: login=renaud@atlog.local(pwd) address=<0x0x557c0633b500[NGInternetSocketAddress]: host=172.42.1.250 port=143>>
        Sep  5 08:56:44 c0dcc9496261 sogod [66]: [ERROR] <0x557c06373700[SOGoMailAccount]:0> Could not connect `IMAP4`
        • DocFraggle replied to this.
        • Well, “connection refused” sounds more like a firewall issue… did you have a look at your firewall logs?

          Please also have a look here and especially at the red warning box