Delete emails from Exim queue

A little reminder of how to delete emails from Exim queue if cPanel queue manager does not work.

cd /var/spool/exim
find input -type f -exec rm -rf {} \;
find msglog -type f -exec rm -rf {} \;
service exim restart

 

Redirect web traffic with Cloudflare and ASP.NET

To redirect web traffic with Cloudflare and ASP.NET first enable IP Geolocation in CloudFlare dashboard:

Redirect web traffic with Cloudflare and ASP.NET

Related article:
http://netjunky.net/redirect-web-traffic-based-on-country-origin/

To learn more about Cloudflare visit there website:
https://www.cloudflare.com/overview

Once enabled, Cloudflare will then add a header called “CF-IPCountry” to all requests to your website.
In your ASP.NET website code capture that header and redirect traffic.

This can be done on single page or globally in global.asax file.

Code example:

if (Request.Headers.AllKeys.Contains("CF-IPCountry"))
{
    Response.Write(Request.Headers["CF-IPCountry"]);
}

Read header and save result in session to use it globally.
Add this code snippet to your global.asax file:

protected void Session_Start(object sender, EventArgs e)
{
   if (Request.Headers.AllKeys.Contains("CF-IPCountry"))
   {
      Session["language"] = Request.Headers["CF-IPCountry"].ToString();
   }
}

That’s all folks!

 

Enable linux root access on Microsoft Azure Cloud

How to enable linux root access on Microsoft Azure Cloud

1. Login via ssh using your sudo user on your Microsoft Azure linux server

2. Now login as root user

[root@lin ~]# sudo su -

3. check if root access is set (LOCK means that root access is disabled)

[root@lin ~]# grep root /etc/shadow

Result:
root:*LOCK*:14600::::::

4. enable root access  (as root user enter command passwd)

[root@lin ~]# passwd

5. Now enter your password and root access is enabled.

You can check this by using command “grep root /etc/shadow”

That’s all folks

 

Redirect web traffic based on Country origin

You can enable IP Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you.
Redirect web traffic based on Country origin to subdomain or to different web site.

You will find the IP geolocation option by going to:
Webiste –>CloudFlare Settings –>IP Geolocation

Direct link is:
https://www.cloudflare.com/cloudflare-settings?z=YOURSITE

Once enabled, Cloudflare will then add a header called “CF-IPCountry” to all requests to your website.

Redirect web traffic based on Country origin

Here are a couple of examples of how to access/store this value:

$country_code = $ENV{"HTTP_CF_IPCOUNTRY"}; # to access in Perl
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; // to access in PHP

CloudFlare includes this information for both IPv4 and IPv6 addresses

In your website code capture that header and redirect traffic.
Redirect web traffic based on Country origin PHP sample:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

if($country_code=="US"){
$location='http://www.mysite.com/us';
}elseif($country_code=="UK"){
$location='http://www.mysite.com/uk';
}else{
$location='http://www.mysite.com/us';
}
header("location:$location");
exit;

Update:

ASP.NET example:
http://netjunky.net/redirect-web-traffic-with-cloudflare-and-asp-net/

Delete exim queue

Delete exim queue sometimes is impossible task.
There are just to many emails and queue manager is to slow.

You can use this dirty trick:

cd /var/spool/exim
find input -type f -exec rm -rf {} \;
find msglog -type f -exec rm -rf {} \;
service exim restart

Warning
This will erase all your emails from queue.