Mikrotik side configuration guide - salehram/mikrotik-proxy-logger GitHub Wiki

Configuration needed on Mikroitk side are 3 parts:

  1. Enabling accounting
  2. Enable web-proxy
  3. Enable logging

Enable Accounting

This is a required configuration because the listener service will try to contact the Mikrotik and take the accounting data form it, so accounting access should be enabled.

To enable accounting, type these commands in Mikrotik terminal window (assuming 192.168.1.0/24 is your local network):

/ip accounting set enabled=yes account-local-traffic=yes
/ip accounting web-access set accessible-via-web=yes address=192.168.1.0/24

Enable web-proxy

This step will allow the Mikrotik to generate the logs for HTTP requests and send them to the target listener service. Note this is only for HTTP and for now HTTPS won't work.

To have the web proxy enabled and setup, these commands will do the job (assuming 192.168.1.0/24 is your local network):

/ip proxy set cache-path=web-proxy1 enabled=yes src-address=192.168.1.1
/ip firewall nat add action=redirect chain=dstnat comment="Redirect port 80 to port 8080 for web proxy" disabled=no dst-port=80 protocol=tcp src-address=192.168.1.0/24 to-ports=8080

The first command will enable the web proxy, and the second one will redirect all HTTP (port 80) traffic to the web proxy listening port (8080).

Enable logging

This is the core and most important setting we need to set, without it, the listener service will not get any updates or data from the Mikrotik.

To enable the logging, we need to first have the following requirements met:

  1. The IP address of the machine that will have the listener service running on it.
  2. By default the Mikrotik will send the data on UDP port 514, we need to make sure that this port is open in the target machine's firewall.

Once the above requirements are checked, we can enable the logging using the following commands (assuming the IP of the target machine you have is 192.168.1.10):

/system logging action add name=sentToMTPLService remote=192.168.1.10 remote-port=514 target=remote
/system logging add action=sentToMTPLService topics=web-proxy,!debug

The first command adds the action which we will use in the next one to create the logging rule.
Once you have these two commands executed, the Mikrotik will be ready to send the data to the listener service.