Ratelimiting with ISPConfig 3 and rspamd

Discussion in 'Installation/Configuration' started by smartapp, Nov 22, 2021 at 5:39 PM.

  1. smartapp

    smartapp New Member

    Hi!
    I'm trying to configure ISPConfig 3 with Rspamd (and it's working, thanks for this nice feature!), but I just wanted to add a global ratelimiter via the ratelimiter module and cannot achieve to limit outgoing mails.
    What i did so far: installed rspamd, updated and reconfigured ISPConfig, added rspamd in mail settings, made a vhost and proxied the dashboard, configured and checked redis connection with spamd (i see the logs from spamd in the specificed redis database).

    I created a small PHP script to send out the same mail 3 times but rate limiter seems to be ignored (redis monitor is dumping requests) but i got on the other side all the 3 mails (and i'm expecting only 1 mail per hour as configured above).

    This configuration lives in /etc/rspamd/local.d/ratelimit.conf - as described in the rspamd ratelimiter docs.
    Code:
    symbol = "R_RATELIMIT";
    info_symbol = "R_RATELIMIT_INFO";
    rates {
      user = {
        selector = "user.lower";
            bucket = [{
          burst = 1;
          rate = "1 / 1min";
        }]
      }
      to = {
        bucket = {
          burst = 100;
          rate = 0.01666666666666666666; # leak 1 message per minute
        }
      }
    }
    
    Any thought / idea is appreciated. Thanks!
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Here's a snippet:
    Code:
    rates {
            user = {
                    bucket = [
                    {
                            burst = 10;
                            rate = "8 / 1m";
                    },
                    {
                            burst = 20;
                            rate = "10 / 10m";
                    },
                    {
                            burst = 120;
                            rate = "100 / 1h";
                    }]
            }
    }
     
    Jesse Norell likes this.
  3. smartapp

    smartapp New Member

    Hi @Th0m , thanks for your time!
    After every change i'm doing a service rspamd restart and rspamadm configtest.
    The last one has the following output:

    Code:
    symbol 'RAMBLER_URIBL' has its score defined but there is no corresponding rule registered
    symbol 'RAMBLER_EMAILBL' has its score defined but there is no corresponding rule registered
    symbol 'URIBL_SBL' has its score defined but there is no corresponding rule registered
    symbol 'URIBL_SBL_CSS' has its score defined but there is no corresponding rule registered
    symbol 'RBL_SARBL_BAD' has its score defined but there is no corresponding rule registered
    syntax OK
    Here is the mail.log:

    Code:
    Nov 23 07:39:12 cloud postfix/pickup[12905]: 8FC26D82F2: uid=0 from=<root>
    Nov 23 07:39:12 cloud postfix/cleanup[19677]: 8FC26D82F2: message-id=<[email protected]>
    Nov 23 07:39:12 cloud postfix/qmgr[1636]: 8FC26D82F2: from=<[email protected]>, size=392, nrcpt=1 (queue active)
    Nov 23 07:39:12 cloud postfix/pickup[12905]: A41E4D820C: uid=0 from=<root>
    Nov 23 07:39:12 cloud postfix/cleanup[19677]: A41E4D820C: message-id=<[email protected]>
    Nov 23 07:39:12 cloud postfix/qmgr[1636]: A41E4D820C: from=<[email protected]>, size=392, nrcpt=1 (queue active)
    Nov 23 07:39:12 cloud postfix/pickup[12905]: B3B06D8445: uid=0 from=<root>
    Nov 23 07:39:12 cloud postfix/cleanup[19677]: B3B06D8445: message-id=<[email protected]>
    Nov 23 07:39:12 cloud postfix/qmgr[1636]: B3B06D8445: from=<[email protected]>, size=392, nrcpt=1 (queue active)
    Nov 23 07:39:12 cloud postfix/pickup[12905]: B8A0CD82F6: uid=0 from=<root>
    Nov 23 07:39:12 cloud postfix/cleanup[19677]: B8A0CD82F6: message-id=<[email protected]>
    Nov 23 07:39:12 cloud postfix/qmgr[1636]: B8A0CD82F6: from=<[email protected]>, size=392, nrcpt=1 (queue active)
    Nov 23 07:39:12 cloud postfix/pickup[12905]: BDCB4D82B5: uid=0 from=<root>
    Nov 23 07:39:12 cloud postfix/cleanup[19677]: BDCB4D82B5: message-id=<[email protected]>
    Nov 23 07:39:12 cloud postfix/qmgr[1636]: BDCB4D82B5: from=<[email protected]>, size=392, nrcpt=1 (queue active)
    Nov 23 07:39:13 cloud postfix/smtp[19698]: B3B06D8445: to=<[email protected]>, relay=mail.recipient.com[123.123.123.123]:25, delay=0.79, delays=0.15/0.01/0.41/0.21, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 5AB5ABA0C4D)
    Nov 23 07:39:13 cloud postfix/qmgr[1636]: B3B06D8445: removed
    Nov 23 07:39:13 cloud postfix/smtp[19699]: B8A0CD82F6: to=<[email protected]>, relay=mail.recipient.com[123.123.123.123]:25, delay=0.89, delays=0.19/0.02/0.57/0.12, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 6D411BA0F1C)
    Nov 23 07:39:13 cloud postfix/qmgr[1636]: B8A0CD82F6: removed
    Nov 23 07:39:13 cloud postfix/smtp[19697]: A41E4D820C: to=<[email protected]>, relay=mx2.recipient.com[123.123.123.123]:25, delay=0.89, delays=0.11/0.01/0.61/0.16, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 7456FBA0F25)
    Nov 23 07:39:13 cloud postfix/smtp[19700]: BDCB4D82B5: to=<[email protected]>, relay=mail.recipient.com[123.123.123.123]:25, delay=0.87, delays=0.15/0.01/0.56/0.15, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 749F5BA0F68)
    Nov 23 07:39:13 cloud postfix/qmgr[1636]: A41E4D820C: removed
    Nov 23 07:39:13 cloud postfix/qmgr[1636]: BDCB4D82B5: removed
    Nov 23 07:39:13 cloud postfix/smtp[19690]: 8FC26D82F2: to=<[email protected]>, relay=mx2.recipient.com[123.123.123.123]:25, delay=0.97, delays=0.1/0.05/0.71/0.1, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 78914BA0F3C)
    Nov 23 07:39:13 cloud postfix/qmgr[1636]: 8FC26D82F2: removed
    EDIT: i've tried the snipped you have provided as well.

    Thanks for your time!
     
    Last edited: Nov 23, 2021 at 8:12 AM
  4. smartapp

    smartapp New Member

    After removing the first two lines, i got it working. Thanks @Th0m for your question!

    Code:
    symbol = "R_RATELIMIT";
    info_symbol = "R_RATELIMIT_INFO";
     
    Th0m likes this.

Share This Page