• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

C API

Need Help?

Introduction

The easiest way to see how the 51Degrees NGINX module performs is to use the example installation on the GitHub repository. Below are the installation steps for this.

Installing

If you haven't already, you can obtain a copy of the latest version of the API using one of the links on Downloads.

To install on a linux system, go to the nginx directory with

$ cd Device-Detection/nginx 

Then install to the local directory with either

$ make install pattern 

or

$ make install trie 

depending on the desired detection method.

Then test the installation was successful by running

$ make test 

To compile the module into an existing Nginx deployment, first clone 51Degrees/Device-Detection repository with

$ git clone https://github.com/51Degrees/Device-Detection.git

Move to the Nginx directory with

$ cd Device-Detection/nginx

and put together the module directory with either

$ make build pattern

or

$ make build trie

Copy the module to the Nginx modules directory with

$ cp -r 51Degrees_module [MODULE DIRECTORY]

In the Nginx source directory, run ./configure as normal and add the module, the linker option -lm and the definitions FIFTYONEDEGREES_PATTERN and FIFTYONEDEGREES_NO_THREADING (or FIFTYONEDEGREES_TRIE for the Trie module). A basic example is,

$ ./configure \
    --prefix=[NGINX INSTALL DIRECTORY] \
    --with-ld-opt="-lm" \
    --with-cc-opt="-DFIFTYONEDEGREES_PATTERN -DFIFTYONEDEGREES_NO_THREADING"
    --add-module=[MODULE DIRECTORY]/51Degrees_module

NOTE: with Pattern the arguments -Wno-ignored-qualifiers -Wno-unused-result are also needed.

Then install with

$ sudo make install

51Degrees can also be build as a dynamic module for Nginx version 1.9 or later.

To build the module as ngx_http_51D_module.so, follow the same instructions as the static build above, but replace the add_module argument with add_dynamic_module. By default, the module will be built to Nginx's module directory. The only extra thing which will need to be added to the config file is the line

load_module modules/ngx_http_51D_module.so;

NOTE: Nginx insists on the same compile arguments being used in both the Nginx executable and the dynamic module.

Next steps:

How to configure the module