WEBVTT

00:07.220 --> 00:12.740
In this final video of the feature section we'll see how to configure Geo IP look ups directly from

00:12.740 --> 00:15.730
Engine X first off to enable this module.

00:15.740 --> 00:22.520
You will have to tell engine extra included by specifying the flag with HTP Geo IP module as we did

00:22.520 --> 00:24.440
with them before module.

00:24.440 --> 00:27.900
Now should you run your configuration and get the following error.

00:27.920 --> 00:35.570
You can install the missing dependency by running app get install the geo IP dash dev or the equivalent

00:35.570 --> 00:38.550
of whichever package manager you're using on your server.

00:38.990 --> 00:44.480
Once that's done we can configure the engine explode with the geo IP flag run that.

00:49.340 --> 00:50.580
And install.

00:52.230 --> 00:53.120
Running engine x.

00:53.130 --> 00:59.790
Capital V will confirm that our engineers install now includes the geo IP module so we can reload the

00:59.790 --> 01:07.080
configuration and start configuring the GOP module to use the GOP module will first need to download

01:07.110 --> 01:15.570
the max mind Geo IP database and for that I'll create a new directories on the server slash ebc slash

01:15.600 --> 01:20.300
engine X slash Geo IP and I'll change into that directory.

01:21.140 --> 01:25.850
Over to the browser and will navigated dev dot Max mind dot com.

01:27.540 --> 01:29.280
And a bit further down the page.

01:29.290 --> 01:30.830
Select Geo light.

01:30.850 --> 01:33.150
Legacy free download.

01:33.580 --> 01:38.760
I'm using the legacy packages as they are arguably still the preferred choice for in gen-x and matched

01:38.770 --> 01:41.360
the documentation of the geo IP module.

01:41.640 --> 01:47.800
The two databases I'm going to download is the geo light country and the geo light city so I'll copy

01:47.800 --> 01:49.090
that download link.

01:51.410 --> 01:54.920
Download the Jesus file to the geo IP directly.

01:55.890 --> 01:57.570
Unzip it using guns up.

01:59.380 --> 02:02.270
Then do the same for the city database.

02:09.130 --> 02:12.720
There we have our two Geo IP database files.

02:12.790 --> 02:17.860
Now I'll switch over to the engine X configuration file and just remove that red limiting rule from

02:17.860 --> 02:23.890
a previous video then to configure Geo IP we're going to tell engine X where to find those databased

02:23.890 --> 02:25.030
files.

02:25.060 --> 02:29.430
This is just done in its tgb context so it's available everywhere.

02:29.440 --> 02:36.730
First will say gee do I be underscore country and say that you slash iti slash engineer X slash Geo

02:36.740 --> 02:39.720
I'd be slashed to you be done to a T.

02:40.000 --> 02:46.110
Which is that first database file we downloaded and then the same for geo IP underscore city.

02:47.800 --> 02:48.420
See.

02:48.440 --> 02:52.730
Slash engineer slash Geo I be slessor Geo light city.

02:52.750 --> 02:54.490
Don't be a T.

02:54.660 --> 02:56.230
Switch over to the terminal.

02:56.270 --> 03:00.400
Check that configuration and something isn't right.

03:02.000 --> 03:04.820
Just a typo in that first file name.

03:05.350 --> 03:06.370
Try again.

03:06.640 --> 03:10.420
And now everything looks fine so I'll reload the configuration.

03:11.060 --> 03:16.760
Right to use the geo IP module will have to specify what information we want and to get a list of all

03:16.760 --> 03:17.530
the variables.

03:17.540 --> 03:18.880
The module makes available.

03:18.890 --> 03:21.870
We'll head over to the documentation page first.

03:21.980 --> 03:24.540
Take a look at Geo IP country.

03:24.560 --> 03:31.040
This provides us with three variables and to demonstrate I am going to use the geo IP country name variable

03:31.040 --> 03:32.030
first.

03:32.520 --> 03:39.060
Back to the configuration file and I'll create a new location block or slash Geo underscore country

03:39.840 --> 03:47.670
and to keep this simple we'll just return a string with response code 200 and we'll say visiting from

03:48.000 --> 03:52.380
Geo IP country name save their own reload.

03:52.910 --> 03:56.450
Head over to the browser and go to that your URL.

03:57.280 --> 03:59.040
Do you underscore country.

04:00.810 --> 04:07.710
And we get visiting from South Africa as that we are recording this video and making the request from.

04:07.740 --> 04:13.200
If however we head over to the terminal and do a call request from this digital ocean server.

04:13.800 --> 04:18.970
We get visiting from United Kingdom as this is a London based virtual machine.

04:19.970 --> 04:25.410
Okay next I'll try the city database and back on that documentation page we can see just a bit further

04:25.410 --> 04:25.830
down.

04:25.830 --> 04:27.640
It's quite a few variables.

04:27.750 --> 04:33.180
In fact using the city database we can get everything from latitude and longitude oesterle code and

04:33.180 --> 04:36.270
city name which will try as well.

04:36.270 --> 04:41.530
So change that your URL to geo underscore city change the variable to Geo.

04:41.530 --> 04:44.550
I be city and reload.

04:45.250 --> 04:51.520
Now unfortunately my city is a bit more remote and isn't returned with this version of the city database

04:51.820 --> 04:53.430
so I'll skip the browser.

04:53.620 --> 05:00.080
But if we do that call request from the digital ocean server again we get visiting from London.

05:00.920 --> 05:06.110
In a real world scenario you could of course use these variables in rewrites to serve location specific

05:06.110 --> 05:10.960
content pass them to a back end or even apply restrictions based on location.

05:10.970 --> 05:15.320
The possibilities are quite endless and overall this is a very useful module to know.
