This example shows how query argument take precendence over header value for 51Degrees' on-premise device detection in Nginx. This example is available in full on GitHub.
This example requires a local data file. The free 'Lite' data file can be acquired by pulling the git submodules under this repository (run `git submodule update --recursive`) or from the device-detection-data GitHub repository.
The Lite data file is only used for illustration, and has limited accuracy and capabilities. Find out about the more capable data files that are available on our pricing page
Make sure to include at least IsMobile property for this to work.
Before using the example, update the followings:
- Remove this 'how to' guide block.
- Update the %%DAEMON_MODE%% to 'on' or 'off'.
- Remove the %%TEST_GLOBALS%%.
- Update the %%MODULE_PATH%% with the actual path.
- Remove the %%TEST_GLOBALS_HTTP%%.
- Update the %%FILE_PATH%% with the actual file path.
- Replace the nginx.conf with this file or run Nginx with
-c
option pointing to this file. - Create a static file
query
in the Nginxdocument_root
.
In a Linux environment, once Nginx has started, run the following command:
The header is a desktop User-Agent while the argument is a mobile User-Agent. Expected output:
NOTE
: All the lines above, this line and the end of comment block line after this line should be removed before using this example.