GEOIP redirect with https in nginx

With the full Nginx Installation with MAP Module active You can redirect based on GEOIP.

You will need the geoip-database installed, on RedHat based system with YUM you will use the following:

yum install geoip geoip-devel

So once you have that installed you will need MaxMind’s City database which can be retrieved from MaxMind’s website.

  1. wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz -O /usr/share/GeoIP/GeoLiteCity.dat.gz
  2. gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz

So now you have the setup out the way you are ready to configure NGINX, which is relatively straightforward.

The example configuration for your case would go something like the following:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
  geoip_city /usr/share/GeoIP/GeoLiteCity.dat;

  map $geoip_city_country_code $nearest_server {
    default example.com;
    CA      example.ca;
  }

  server{
      listen 80;
      listen [::]:80;
      server_name example.com
                  example.ca;

      if ($nearest_server != $host) {
        rewrite ^ $scheme://$nearest_server$request_uri break;
      }

  }
}

So, specifics: In the configuration above it does depend on your installation so you’ll need to ensure that the include, error_log and pid directory is correct to your installation and preference.

In respect of how it works, I believe it’s pretty self-explanatory however to delve into it a bit:

geoip_city /usr/share/GeoIP/GeoLiteCity.dat; > links the downloaded MaxMind GeoIP city data to NGINX.

  map $geoip_city_country_code $nearest_server {
    default example.com;
    CA      example.ca;
  }

The above section links your multiple hosts, and their respective country code, e.g. CA for Canada- you can add as many entries as you want.

  if ($nearest_server != $host) {
    rewrite ^ $scheme://$nearest_server$request_uri break;
  }

The above section decides what server based to use based on location, and passes on the request URI. Example http://example.com/store.php requested from a Canadian IP will redirect to http://example.ca/store.php

That is pretty much it, the main sections are the MAP section, and the IF statement within the server component (and fulfilment of the requirements)

WordPress best plugin for website security

  • Sucuri

Sucuri is the multi-functioned high profile security plugins which help you to notify the login attempts via email or other means. It helps to detect the malware or any malicious virus codes and clean it on time. It can be scheduled to check your entire website in hours, days or weeks. It provides complete security to WordPress blogs. This plugin usually includes all the security options so you do not have to install any other security plugin, also using too many plugins will slow down your website.

  • Login LockDown

This plugin is used to protect your website from brute force attacks. Brute force attacks usually attempt a thousand times to login to your dashboard using the different password combinations. Once they get the right one, they’ll take it all. Login LockDown

helps your website to limit the login attempts so that you can only login once, twice or thrice. You can set the number of login attempts to be made while logging in. It automatically blocks the IP which will try to fake login more than 2-3 times in the dashboard.

  • WP Security Scan

WP security scan is the free WordPress plugin easily available in the WordPress plugin directory. It helps the user to easily monitor the login attempts via email, password change notifications also helps to optimize the website data. It helps you to change the login form links and other secure area by changing their directory or names. It can be programmed to change the .htaccess and other secure files so that it cannot be shown publicly.

  • Wordfence

The Wordfence WordPress security plugin provides free enterprise-class WordPress security, protecting your website from hacks and malware. It helps to scan the viruses and malware data in your wp directories and files. This is the most popular security plugin for WordPress. Wordfence starts by checking if your site is already infected or not. If it has been infected it scans it and clears all the complications in your blog. It is a free plugin and also has an open-source license. Its features usually include:

      • Blocking Features
      • Login Security
      • Security Scanning
      • WordPress Firewall
      • Monitoring & Caching
      • Compatibility
  • Akismet

Last but not the least plugin which is very very important for every blogging website. The attackers are inventing new techniques daily to hack the growing blogs. This is a web server based plugin for checking the spam comments on your blog. When any hacker post a spam comment on your blog, Akismet
will check and verify that whether it is infected or not. It automatically checks all comments and filters the spam one. Comment hacking was newly discovered in the hacking technique. If someone post that code in your blog and you saw it mistakenly, they will get the .htaccess of your website from which they can easily reveal the Username and Password of your wp-admin dashboard.

Systron Micronix offers SiteLock, cWatch Security Solutions for websites.

What makes Web Hosting With Systron Micronix the best?

All of our shared web hosting weathers its Linux Shared Hosting or Windows shared hosting plans are carefully tailored to suit everyone. Apart from the standard features like domain name registrations/transfers, 24/7 technical support, 99.9% uptime, etc., we give you a vast array of tools to take your thoughts or business online fast! From site building tools and templates, to our one-click application installer, everything you need to launch a website is literally at your fingertips.

Continue reading “What makes Web Hosting With Systron Micronix the best?”