Jun 012011
 
nginx logo

Nginx

I’ve found something interesting in the nginx mailing list today http://forum.nginx.org/read.php?2,202715,202715#msg-202715 . someone asked whether it is possible to block fake user agent such as google bot. sometimes, a lot of bots flood our servers disguise as google bot or other legal bot. Most likely, to scrape our website’s contents. Original google bot always uses the ip address which is owned by Google Inc. Many website owners complained, bad bots only drain their bandwidth usage. 🙂

The first option to use “if” directive in nginx.

if ($http_user_agent ~* "Google Bot") {
	allow 66.x;
	allow 70.x;
	deny all;
}

However, “if” directive considered to be a bad practice when use for anything rather than “return” or “rewrite”. Here’s an example from Igor Sysoev:
Continue reading »

Sep 042009
 

i’ve just found that some clever user spoofing their sender email address. They’re relaying email from my office webmail i’ve been maintained for years. so here’s the solution to evade naughty user from sending their bulk email.

I’m using postfix, so in main.cf i added restriction class like this

smtpd_restriction_classes = has_our_domain_as_sender
has_our_domain_as_sender = check_sender_access hash:/etc/postfix/mydomains, reject 

in mydomains file

domain.com OK
domain.org OK

Don’t forget to postmap

# postmap mydomains

Now, in smtpd_recipient_restrictions section add this

smtpd_recipient_restrictions =
  check_client_access hash:/etc/postfix/internal_networks,
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unauth_destination,
  reject_unlisted_recipient,
  ....... 

in internal_networks file

127.0.0.1          has_our_domain_as_sender
192.168.1          has_our_domain_as_sender
192.168.2          has_our_domain_as_sender

as usual don’t forget to postmap the file

# postmap internal_networks

Reload postfix

# postfix reload

In squirrelmail config.php file

$domain                 = 'domain.tld';
$imapServerAddress      = 'localhost';
$imapPort               = 143;
$useSendmail            = false;
$smtpServerAddress      = 'localhost';
$smtpPort               = 25; 

we’ve set $useSendmail to false, because if using sendmail email will directly injected to pickup and then cleanup, bypassing all smtpd_*_restrictions.

done