Technical Articles
F5 SMEs share good practice.
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner
F5 Employee
F5 Employee

GeoIP allows you to find the geological location of a host based on its IP address. The information typically includes the country, city, latitude, and longitude. The types of data you get and their granularity and accuracy depend on database you use. This article demonstrates how we can utilize the geoip-lite Node.js module on LineRate. In this example, a LineRate VirtualServer injects two headers containing GeoIP information to the client requests in order to provide the information to the back-end HTTP servers for use in their applications.

To install the geoip-lite Node.js module, execute the following LineRate command.

scripting npm install geoip-lite

If you have received an error message, please refer to the section on LRS-26399 in LineRate Release Notes, Version 2.5.0.

Here is the script. Make sure to change the virtual server ID in the 2nd argument of vsm.on (line #18).

'use strict';
var geoip = require('geoip-lite');
var vsm = require('lrs/virtualServerModule');

var proc = function(servReq, servResp, cliReq) {
  var g = geoip.lookup(servReq.connection.remoteAddress);
  if (g) {
    if (g['ll']) {
      servReq.addHeader('Geo-Position', g['ll'].join(';'));
    if (g['country']) {
      servReq.addHeader('Geo-Country', g['country']);

vsm.on('exist', 'vs1', function(vso) {
  vso.on('request', proc);
Version history
Last update:
‎05-Jun-2023 22:11
Updated by: