Block Countries Behind ELB

To block countries behind an ELB (Elastic Load Balancer) you should use Maxmind’s GeoIP Country Database.

Problem

You are unable to use iptables or ipset to block countries because of your Amazon Elastic Load Balancer

Solution

Use Maxmind’s GeoIP Country Database in conjunction with Apache or NGINX

Example

This example is for Ubuntu 12.04 (Precise)

. . . → Read More: Block Countries Behind ELB

Ubuntu Set Timezone to UTC

Objective: Set Timezone to UTC on Ubuntu 12.04 LTS Howto

You will be using tzdata and ntpdate

Setting the timezone

After running this select “etc” (hit enter) then select “UTC” (hit enter)

pkg-reconfigure tzdata Syncing the clock apt-get -y install ntpdate ntpdate pool.ntp.org Updating crontab to sync clock daily crontab -l > tmp.cron echo “@daily . . . → Read More: Ubuntu Set Timezone to UTC

Apache ProxyPass with dynamic hostname

To use Apache ProxyPass directives with dynamic hostnames you will need to also use ModRewrite.

Objective

All requests to the virtualhost will ProxyPass and ProxyPassReverse (also known as an “Apache Gateway”) to the %{HTTP_HOST}

The only reason this would make sense to do is if you have localhost entries on the apache server for specfic . . . → Read More: Apache ProxyPass with dynamic hostname

curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

Problem

When running curl you get this response:

curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) Solution curl -ssl3

Ensure Beaver Log Shipping is Running

I have a love hate relationship with the beaver log shipper and ensuring that it is in fact running on all of my machines (and not in a defunct or partially running state)

I have finally whipped up a script to take care of this issue and thought i’d share it for anyone that cares.

. . . → Read More: Ensure Beaver Log Shipping is Running

my bash prompt

Installation

Modify ~/.bashrc and append this line

PS1=”\n\[\e[32;1m\][\[\e[37;1m\]\u@\h:\[\e[37;1m\]\w\[\e[32;1m\]]\\$ \[\e[0m\]” My Bash Prompt

Setup Email on Centos

To setup email on Centos 6 run these commands yum -y install sendmail mailutils chkconfig –levels 235 sendmail on service sendmail restart To send a test email echo “test message” | mail -s “test subject” [email protected] Hosts File

Modify your hosts file and add $HOSTNAME.local to prevent issues (in example below we are using hostname . . . → Read More: Setup Email on Centos

Add Current PATH to crontab

Add Current PATH to crontab

Are you sick of your cron job failing because you are not explicitly listing the full path of everything in your shell script? Here’s how to fix it!

Problem

Your script works when you run it from the console but fails in cron.

Cause

Your crontab doesn’t have the right . . . → Read More: Add Current PATH to crontab

How to Send Mail From Ubuntu Precise

Configuration

To send mail from the command line in Ubuntu Precise

sudo apt-get install mailutils

If you mess up configuring or want to reconfigure

dpkg-reconfigure mailutils Sending your test email

Let’s send a test email!

echo “test email body” | mail -s “test email subject” [email protected] Debugging issues tail -f /var/log/mail.err tail -f /var/log/mail.log Config . . . → Read More: How to Send Mail From Ubuntu Precise

restart service over ssh

I recently ran in to trouble restarting neo4j over ssh

here’s the fix:

From machine calling neo4j host ssh -f $USER@$HOST ‘sh -c “( (nohup sudo /etc/init.d/neo4j-service restart 2>&1 >output.file </dev/null) & )”‘ Target Machine Sudoers

Replace “someuser” with whatever user name you want

someuser ALL=NOPASSWD:/etc/init.d/neo4j-service * References starting-remote-script-via-ssh-containing-nohup git-hub-neo4j-issue (I’ve also documented this on . . . → Read More: restart service over ssh