Tutorial for Logwatch on Debian for Nginx with Postfix configuration as "Satellite system"


#1

This tutorial is licensed under CC-BY-SA - feel free to share and modify it (but keep information free)!

:triangular_flag_on_post: This tutorial was originally written for the first Seafile forum of Seafile GmbH. Since the announcement to fork Seafile by Seafile GmbH I’ve decided to move my tutorials to the new Seafile forum of the original developers of Seafile (so this one).
This tutorial version is the maintained one.


Tutorial for Logwatch on Debian for Nginx with Postfix configuration as “Satellite system”

(This tutorial is an add-on for Tutorial for Seafile CE + Nginx + dynamic DNS (on ARM / Cubietruck / RaspberryPi))

Setting up Logwatch

sudo -s
apt-get update && apt-get install logwatch
cp /usr/share/logwatch/default.conf/logfiles/http.conf /etc/logwatch/conf/logfiles/nginx.conf
cp /usr/share/logwatch/default.conf/services/http.conf /etc/logwatch/conf/services/nginx.conf
cp /usr/share/logwatch/scripts/services/http /usr/share/logwatch/scripts/services/nginx
cp /usr/share/logwatch/default.conf/services/http-error.conf /etc/logwatch/conf/services/nginx-error.conf
cp /usr/share/logwatch/scripts/services/http-error /etc/logwatch/scripts/services/nginx-error

cp /etc/logwatch/conf/logfiles/nginx.conf /etc/logwatch/conf/logfiles/nginx.conf_org
<youreditor> /etc/logwatch/conf/logfiles/nginx.conf

Look for these two lines:

LogFile = apache/*access.log
Archive = apache/access.log..gz

and change them to:

LogFile = nginx/*access.log
Archive = nginx/access.log..gz

Go on with:

cp /etc/logwatch/conf/services/nginx.conf /etc/logwatch/conf/services/nginx.conf_org
<youreditor> /etc/logwatch/conf/services/nginx.conf

Change:

Title = "httpd"

# Which logfile group...
LogFile = http

to:

Title = "nginx"

# Which logfile group...
LogFile = nginx

Open /etc/cron.daily/00logwatch:

<youreditor> /etc/cron.daily/00logwatch

Edit:

#execute
/usr/sbin/logwatch --output mail

to:

#execute
/usr/sbin/logwatch --output mail --mailto your@email.add --format text --detail high --range yesterday

Restart cron:

service cron restart

Test Logwatch:

logwatch --detail high --range today

sources:


Setting up Postfix as “Sattelite system”

sudo apt-get install postfix libsasl2-modules bsd-mailx

During setup a wizard will ask your for server type, choose: "Satellite system"
set for “System mail name”: your.ddns.address
and change “smtp.localhost” to: [smtpofyourprovider.tld]:PortNumber

cp /etc/postfix/main.cf /etc/postfix/main.cf_org
<youreditor> /etc/postfix/main.cf

Add the following lines:

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noplaintext noanonymous
# delete "noplaintext" above if passwords have to be sent in clear text which is sometimes the case (but not recommended)
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_security_level = may
sender_canonical_maps = hash:/etc/postfix/sender_canonical

Let Postfix know your password for your@email.add:

touch sasl_passwd
<youreditor> sasl_passwd

To let postifx know your login credentials add and edit the following line:

[smtp.yourmailprovider.com]:587 your@email.add:yourpassword

Go on with:

chmod 600 /etc/postfix/sasl_passwd
postmap hash:/etc/postfix/sasl_passwd

Link system users to your@email.add:

touch /etc/postfix/sender_canonical
<youreditor> /etc/postfix/sender_canonical

Add and edit the following lines:

<yoursystemuser> your@email.add
www-data your@email.add
root your@email.add

Let postfix know these settings:

postmap /etc/postfix/sender_canonical

Restart postfix:

/etc/init.d/postfix reload

To test your postfix:

echo "Test mail from postfix" | mail -s "Test Postfix" your@email.add

-> if you don’t receive any mails try to delete noplaintext in /etc/postfix/main.cf as explained above!

Now test mail delivery for Logwatch:

logwatch --detail low --range yesterday --mailto your@email.add

If you want you can remove /etc/postfix/sasl_passwd now with:

rm /etc/postfix/sasl_passwd

If you don’t receive mails but some cron errors maybe your root account is disabled. To unlock it use:

usermod --unlock --expiredate '' root

source: https://wiki.ubuntuusers.de/postfix

Please:

  1. report any bugs in this thread :bangbang:
  2. report if it works and if some sentences/comments are confusing (and why). :bangbang:
  3. ask all questions in this thread and not via PM (there are no stupid questions for me) :bangbang: