Archive for September 2010

nginx auth – allowing IP or password-based access

nginx uses similar syntax to that of Apache to allow users to access a directory, depending if their IP or username/pass matches (i.e. you want all users to present a valid username/pass match, but want to let some automated checks coming from specified IPs through, i.e. from ldirectord or nagios). Here is an example.
Continue reading ‘nginx auth – allowing IP or password-based access’ »

Source port routing

Sometimes, you may want some services (i.e. web) to be routed through a different interface. Here is a quick setup with some common problems.
Continue reading ‘Source port routing’ »

Getting IP address and aliases in Perl

This piece of Perl code should get you IP address for eth0 into $ip variable:

my $ip;
my $device = "eth0";
if ((`/sbin/ifconfig $device`) =~ /inet addr:(\d+\.\d+\.\d+\.\d+)/) {
    $ip = $1;
}

If you’d also like to get a list of all aliases the device has, you could use something like:
Continue reading ‘Getting IP address and aliases in Perl’ »