Posts Tagged ‘system’

Length Errors in Apache Bench

May 4th, 2009

Are you seeing errors for content length in your Apache Bench tests of your webserver?

I had a hell of a time wondering what was going wrong with my webserver under load and finally found the answer here.

Turns out that Apache Bench takes the first pulled request and compares the length to all subsequent requests. Makes sense for a purely static page, but when you have a random image cropping up, you’re sure to see at least a couple bits difference in length.

So if you’re serving straight, hand coded HTML, enjoy the feeling of knowing that you’re getting the same length content each and every time… but if you’re like the rest of us (and anyone who would actually be using Apache Bench) feel free to rage that there’s no command line switch to turn off that silly notification.

Sweetcron Stream Updating Cron Job

April 20th, 2009

So the Sweetcron documentation isn’t altogether clear on what you should put in cron for it to update automatically, rather than slowing down a user every 30 minutes.

It’s fairly intuitive, but for those missing this logical step, do the following.

Change the setting in the admin panel from psuedo-cron to true-cron, and take note of the URL.

Then put the following in your crontab file (easily accessed with ‘crontab -e’ on a debian machine):

1
*/5 * * * * curl http://your/true-cron/url

You can change the 5 to be the number of minutes between updates that you want, and you’ll definitely want to change the URL to the one listed in your Sweetcron’s admin page.

Configuring Spamassassin as a Daemon on Ubuntu Intrepid

March 20th, 2009

Here is the process I took to install Spamassassin as a daemon working with Postfix to process incoming mail.

I’ll also be trying to reduce the memory footprint while still getting acceptable performance. Mind you, this is being implemented on a low volume server, so these settings may not be applicable to a production server with lots of users.

First, let’s do some prep work

1
2
3
4
5
$ sudo aptitude install spamassassin spamc
$ sudo groupadd -u 5001 spamd
$ sudo useradd -u 5001 -g spamd -s /sbin/nologin -d /var/lib/spamassassin spamd
$ sudo mkdir /var/lib/spamassassin
$ sudo chown spamd:spamd /var/lib/spamassassin

Now edit /etc/default/spamassassin and change the lines below

1
2
3
4
# /etc/default/spamassassin
ENABLED=1
SAHOME="/var/lib/spamassassin"
OPTIONS="--create-prefs --max-children 2 --username spamd -H ${SAHOME}"

Edit /etc/spamassassin/local.cf

1
2
3
4
5
6
7
8
ENABLED=1
rewrite_header Subject **SPAM _SCORE_**
required_score 5.0
use_bayes 1
bayes_auto_learn 1
use_dcc 0
use_pyzor 0
use_razor2 0

Now edit /etc/postfix/master.cf and change it to look like this:

1
2
3
4
5
6
7
8
9
# /etc/postfix/master.cf
26   inet  n - - - - smtpd
     -o content_filter=spamassassin

# Add this segment to end of file
# Spamassassin processing filter
spamassassin unix - n n - - pipe
     user=spamd argv=/usr/bin/spamc -e
     /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Now reboot some stuff

1
2
$ sudo /etc/init.d/spamassassin restart
$ sudo postfix reload

Now test by sending email to yourself. If you view the full headers it should now have X-SPAM headers in it.

If you send an email with “XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X” in the body of the email, it is guaranteed to be flagged as SPAM, and is a great way to test your spam filter.