In this final video of the feature section we'll see how to configure Geo IP look ups directly from
Engine X first off to enable this module.
You will have to tell engine extra included by specifying the flag with HTP Geo IP module as we did
with them before module.
Now should you run your configuration and get the following error.
You can install the missing dependency by running app get install the geo IP dash dev or the equivalent
of whichever package manager you're using on your server.
Once that's done we can configure the engine explode with the geo IP flag run that.
And install.
Running engine x.
Capital V will confirm that our engineers install now includes the geo IP module so we can reload the
configuration and start configuring the GOP module to use the GOP module will first need to download
the max mind Geo IP database and for that I'll create a new directories on the server slash ebc slash
engine X slash Geo IP and I'll change into that directory.
Over to the browser and will navigated dev dot Max mind dot com.
And a bit further down the page.
Select Geo light.
Legacy free download.
I'm using the legacy packages as they are arguably still the preferred choice for in gen-x and matched
the documentation of the geo IP module.
The two databases I'm going to download is the geo light country and the geo light city so I'll copy
that download link.
Download the Jesus file to the geo IP directly.
Unzip it using guns up.
Then do the same for the city database.
There we have our two Geo IP database files.
Now I'll switch over to the engine X configuration file and just remove that red limiting rule from
a previous video then to configure Geo IP we're going to tell engine X where to find those databased
files.
This is just done in its tgb context so it's available everywhere.
First will say gee do I be underscore country and say that you slash iti slash engineer X slash Geo
I'd be slashed to you be done to a T.
Which is that first database file we downloaded and then the same for geo IP underscore city.
See.
Slash engineer slash Geo I be slessor Geo light city.
Don't be a T.
Switch over to the terminal.
Check that configuration and something isn't right.
Just a typo in that first file name.
Try again.
And now everything looks fine so I'll reload the configuration.
Right to use the geo IP module will have to specify what information we want and to get a list of all
the variables.
The module makes available.
We'll head over to the documentation page first.
Take a look at Geo IP country.
This provides us with three variables and to demonstrate I am going to use the geo IP country name variable
first.
Back to the configuration file and I'll create a new location block or slash Geo underscore country
and to keep this simple we'll just return a string with response code 200 and we'll say visiting from
Geo IP country name save their own reload.
Head over to the browser and go to that your URL.
Do you underscore country.
And we get visiting from South Africa as that we are recording this video and making the request from.
If however we head over to the terminal and do a call request from this digital ocean server.
We get visiting from United Kingdom as this is a London based virtual machine.
Okay next I'll try the city database and back on that documentation page we can see just a bit further
down.
It's quite a few variables.
In fact using the city database we can get everything from latitude and longitude oesterle code and
city name which will try as well.
So change that your URL to geo underscore city change the variable to Geo.
I be city and reload.
Now unfortunately my city is a bit more remote and isn't returned with this version of the city database
so I'll skip the browser.
But if we do that call request from the digital ocean server again we get visiting from London.
In a real world scenario you could of course use these variables in rewrites to serve location specific
content pass them to a back end or even apply restrictions based on location.
The possibilities are quite endless and overall this is a very useful module to know.