Skip to main content
ubuntuask.com

Back to all posts

How to Get A Real Client IP Directly From NGINX?

Published on
5 min read
How to Get A Real Client IP Directly From NGINX? image

Best Tools to Buy for Accurate IP Tracking in NGINX in November 2025

1 Tracker Tag 4 Packs Bluetooth Tracker, Smart Tag Locator Tracking Device, Keys Finder and Item Locator,Air Tracker Item Finders with Find My(iOS Only) Track Your Keys,Wallet,Luggage (Black)

Tracker Tag 4 Packs Bluetooth Tracker, Smart Tag Locator Tracking Device, Keys Finder and Item Locator,Air Tracker Item Finders with Find My(iOS Only) Track Your Keys,Wallet,Luggage (Black)

  • EFFORTLESS TRACKING: REAL-TIME LOCATION UPDATES VIA FINDMY APP.

  • COMPACT DESIGN: STYLISH, LIGHTWEIGHT, AND FITS EASILY ON KEYCHAINS.

  • PEACE OF MIND: ALARM ALERTS WHEN ITEMS LEAVE PRESET SAFE ZONES.

BUY & SAVE
$19.99
Tracker Tag 4 Packs Bluetooth Tracker, Smart Tag Locator Tracking Device, Keys Finder and Item Locator,Air Tracker Item Finders with Find My(iOS Only) Track Your Keys,Wallet,Luggage (Black)
2 Esky Key Finder Locator with Sound, Stick-on TV Remote Control Finder, Item Locator Tags with 85dB Noise Sound 6 Receivers, Wallet Tracker Key Finders for Finding Keys, Remote Gift Idea

Esky Key Finder Locator with Sound, Stick-on TV Remote Control Finder, Item Locator Tags with 85dB Noise Sound 6 Receivers, Wallet Tracker Key Finders for Finding Keys, Remote Gift Idea

  • 85DB SOUND + FLASHING LED: LOCATE ITEMS QUICKLY, EVEN IN DARK!

  • LONG BATTERY LIFE: ENJOY UP TO A YEAR WITHOUT BATTERY SWAPS!

  • 100FT TRACKING RANGE: FIND LOST ITEMS THROUGH WALLS AND FURNITURE!

BUY & SAVE
$29.99
Esky Key Finder Locator with Sound, Stick-on TV Remote Control Finder, Item Locator Tags with 85dB Noise Sound 6 Receivers, Wallet Tracker Key Finders for Finding Keys, Remote Gift Idea
3 Tile by Life360 Mate - Bluetooth Tracker, Keys Finder and Item Locator for Keys, Bags and More. Phone Finder. Both iOS and Android Compatible. 1-Pack (Pink Punch)

Tile by Life360 Mate - Bluetooth Tracker, Keys Finder and Item Locator for Keys, Bags and More. Phone Finder. Both iOS and Android Compatible. 1-Pack (Pink Punch)

  • PROTECT VALUABLES EFFORTLESSLY-ATTACH TILES TO EVERYDAY ESSENTIALS!
  • DISCREET SOS ALERTS KEEP YOUR FAMILY SAFE IN EMERGENCIES.
  • EASILY FIND LOST ITEMS AND YOUR PHONE WITH OUR HANDY APP!
BUY & SAVE
$27.99
Tile by Life360 Mate - Bluetooth Tracker, Keys Finder and Item Locator for Keys, Bags and More. Phone Finder. Both iOS and Android Compatible. 1-Pack (Pink Punch)
4 Reyke Key Finder, 80dB+ RF Item Locator Tags with 131ft. Working Range, Wireless Remote Tracker for Wallet, Phone, Glasses, Pet, 1 RF Transmitter & 4 Receivers

Reyke Key Finder, 80dB+ RF Item Locator Tags with 131ft. Working Range, Wireless Remote Tracker for Wallet, Phone, Glasses, Pet, 1 RF Transmitter & 4 Receivers

  • NEVER LOSE VALUABLES AGAIN: PRESS, BEEP, AND FIND LOST ITEMS EASILY!

  • RAPID RECOVERY: LOUD 80DB SOUND & LED LIGHT TO LOCATE IN DARKNESS.

  • LONG-LASTING POWER: COMES WITH BATTERIES FOR EXTENDED TRACKING USE.

BUY & SAVE
$14.99 $18.99
Save 21%
Reyke Key Finder, 80dB+ RF Item Locator Tags with 131ft. Working Range, Wireless Remote Tracker for Wallet, Phone, Glasses, Pet, 1 RF Transmitter & 4 Receivers
5 NOYAFA NF-8506 Network Cable Tester with RJ45 Crimp Tool, CAT5 CAT6 Network Tester, IP Scan, PoE Ping Test, Network Rate Test, Port Flashing, RJ45 RJ11 Ethernet Cable Tester with Crimper Stripper

NOYAFA NF-8506 Network Cable Tester with RJ45 Crimp Tool, CAT5 CAT6 Network Tester, IP Scan, PoE Ping Test, Network Rate Test, Port Flashing, RJ45 RJ11 Ethernet Cable Tester with Crimper Stripper

  • DIAGNOSE NETWORKS FAST WITH PING & IP SCANNING CAPABILITIES.
  • ALL-IN-ONE TOOL FOR CRIMPING, CUTTING, AND TESTING CABLES.
  • EFFICIENTLY IDENTIFY POE DEVICES AND TROUBLESHOOT CABLE ISSUES.
BUY & SAVE
$139.99
NOYAFA NF-8506 Network Cable Tester with RJ45 Crimp Tool, CAT5 CAT6 Network Tester, IP Scan, PoE Ping Test, Network Rate Test, Port Flashing, RJ45 RJ11 Ethernet Cable Tester with Crimper Stripper
6 Luubom Key Finder 80DB+ Tracking Devices, Item Locator Tags with 164ft, Wireless Locator for Finding Wallet Phone Glasses Pet, 1 RF Transmitter & 4 Receivers

Luubom Key Finder 80DB+ Tracking Devices, Item Locator Tags with 164ft, Wireless Locator for Finding Wallet Phone Glasses Pet, 1 RF Transmitter & 4 Receivers

  • FIND LOST ITEMS IN SECONDS WITH A LOUD 75-85 DB ALARM!

  • ONE-TOUCH SETUP-TRACK ITEMS UP TO 164 FEET AWAY!

  • LASTS 12 MONTHS ON STANDBY; PERFECT FOR ANY FREQUENT ITEMS.

BUY & SAVE
$21.99
Luubom Key Finder 80DB+ Tracking Devices, Item Locator Tags with 164ft, Wireless Locator for Finding Wallet Phone Glasses Pet, 1 RF Transmitter & 4 Receivers
7 REOLINK PTZ Security Camera System 4K, IP PoE 360 Camera with Dual-Lens, Auto 6X Hybrid Zoomed Tracking, 355 Pan & 90 Tilt, Outdoor Surveillance, AI Detection, TrackMix PoE

REOLINK PTZ Security Camera System 4K, IP PoE 360 Camera with Dual-Lens, Auto 6X Hybrid Zoomed Tracking, 355 Pan & 90 Tilt, Outdoor Surveillance, AI Detection, TrackMix PoE

  • DUAL VIEW CAPTURES EVERY DETAIL AND PANORAMIC VIEW IN ONE SCREEN.
  • AUTO TRACKING AND 6X HYBRID ZOOM FOR PRECISE MONITORING NEEDS.
  • INSTANT ALERTS KEEP YOU SAFE WITH NOTIFICATIONS AND TRIGGERED DEFENSES.
BUY & SAVE
$151.99 $189.99
Save 20%
REOLINK PTZ Security Camera System 4K, IP PoE 360 Camera with Dual-Lens, Auto 6X Hybrid Zoomed Tracking, 355 Pan & 90 Tilt, Outdoor Surveillance, AI Detection, TrackMix PoE
8 Remote Control Finder, Pack of 4 Find My Keys Device | Stick on Remote Finder Beeper, Tracker Tags for Car Keys and Phones | 120Ft Range 80dB RF Key Locator, Lost Key Finders That Make Noise

Remote Control Finder, Pack of 4 Find My Keys Device | Stick on Remote Finder Beeper, Tracker Tags for Car Keys and Phones | 120Ft Range 80dB RF Key Locator, Lost Key Finders That Make Noise

  • NO APP NEEDED: QUICKLY FIND ITEMS WITH A SIMPLE PRESS & BEEP.
  • 120FT RANGE: LOCATE LOST KEYS OR PETS EASILY FROM UP TO 120 FEET.
  • PORTABLE & VERSATILE: PERFECT FOR INDOOR/OUTDOOR USE WITH SLEEK DESIGN.
BUY & SAVE
$16.97 $18.97
Save 11%
Remote Control Finder, Pack of 4 Find My Keys Device | Stick on Remote Finder Beeper, Tracker Tags for Car Keys and Phones | 120Ft Range 80dB RF Key Locator, Lost Key Finders That Make Noise
9 Lost Remote Finder, Remote Control Finder Locator with LED Light | 131ft RC Range Key Finder Locator Making Noise, Find My Keys Device with 4 Remote Retriever Tags | Key Tracker, Keychain Key Finder

Lost Remote Finder, Remote Control Finder Locator with LED Light | 131ft RC Range Key Finder Locator Making Noise, Find My Keys Device with 4 Remote Retriever Tags | Key Tracker, Keychain Key Finder

  • PRESS, BEEP & FIND-EASILY TRACK ANY ITEM ANYWHERE!

  • LOUD 85DB ALERTS REACH 131FT-PERFECT FOR ANY ENVIRONMENT!

  • PORTABLE DESIGN & LED FLASHLIGHT-IDEAL FOR INDOOR & OUTDOOR!

BUY & SAVE
$17.98
Lost Remote Finder, Remote Control Finder Locator with LED Light | 131ft RC Range Key Finder Locator Making Noise, Find My Keys Device with 4 Remote Retriever Tags | Key Tracker, Keychain Key Finder
+
ONE MORE?

To get the real client IP directly from NGINX, you can use the ngx_http_realip_module module. This module allows NGINX to replace the client IP address in the request headers with the address sent in the X-Forwarded-For or X-Real-IP headers.

Follow these steps to configure NGINX to obtain the real client IP:

  1. Open the NGINX configuration file typically located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf.
  2. Inside the http block, add the following line to load the ngx_http_realip_module module: load_module /usr/lib/nginx/modules/ngx_http_realip_module.so;
  3. Within the http block, add the following lines to set the real_ip_header variable to the appropriate header value: set_real_ip_from 10.0.0.0/8; real_ip_header X-Forwarded-For; Replace 10.0.0.0/8 with the appropriate CIDR notation for your trusted proxy IP address or subnet range.
  4. Below the previous lines, add the following line to restore the original client IP address: real_ip_recursive on;
  5. Save the configuration file and exit the text editor.
  6. Test the NGINX configuration for syntax errors: nginx -t
  7. If the test is successful, reload NGINX to apply the changes: systemctl reload nginx

Once NGINX is configured, it will use the value from the X-Forwarded-For or X-Real-IP header as the client IP address instead of the default value obtained by NGINX. This allows you to accurately trace the client IP in your NGINX logs or use it for any other purposes within your NGINX configuration.

How to configure NGINX to obtain the client IP address?

To configure NGINX to obtain the client IP address, you can follow these steps:

  1. Open your NGINX configuration file. Depending on the operating system and NGINX installation method, the file could be located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf or /etc/nginx/sites-available/default.
  2. Inside the main http block, add or modify the http or server block to include the following line: set_real_ip_from 0.0.0.0/0; # Set the IP range from which NGINX should trust proxy requests real_ip_header X-Forwarded-For; # The header that contains the real IP address Alternatively, if you're behind a load balancer or reverse proxy, you can use the X-Real-IP header instead of X-Forwarded-For: real_ip_header X-Real-IP;
  3. Save the configuration file and exit the editor.
  4. Test the configuration syntax for any errors by running the command: nginx -t
  5. If there are no syntax errors, reload the NGINX configuration to apply the changes by running the command: nginx -s reload

After configuring NGINX to obtain the client IP address, you can access it in your application or web server logs using the REMOTE_ADDR environment variable.

How to check if NGINX is running on a server?

You can use the following command to check if NGINX is running on a server:

sudo systemctl status nginx

This command will display the status of the NGINX service. If NGINX is running, you will see output similar to:

● nginx.service - The NGINX HTTP Server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-04-13 10:00:00 PDT; 1h ago Docs: http://nginx.org/en/docs/ Main PID: 12345 (nginx) Tasks: 2 (limit: 4915) Memory: 4.0M CPU: 1.000s CGroup: /system.slice/nginx.service ├─12345 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; └─12346 nginx: worker process

If NGINX is not running, you will see output indicating that the service is inactive or not found.

Note: The exact command may vary depending on the operating system and how NGINX is installed on the server.

What is an NGINX rewrite rule?

An NGINX rewrite rule is a configuration setting that allows rewriting or modifying URL paths or query strings sent by clients before processing the request. It enables the server to redirect or serve content from different locations based on certain conditions defined by regular expressions. NGINX rewrite rules are commonly used for URL redirection, modifying query strings, masking internal file paths, and implementing SEO-friendly URLs.

How to block specific IP addresses using NGINX?

To block specific IP addresses using NGINX, you can follow these steps:

  1. Open the NGINX configuration file. This file is typically located in the /etc/nginx/ directory and is named nginx.conf.
  2. Inside the http block, add a new server block to define the configurations for blocking the IP addresses: http { ... server { ... } }
  3. Inside the server block, add a new location block to specify the path or URL where you want to block the IP addresses: http { ... server { ... location /block/path { ... } } }
  4. Inside the location block, use the deny directive to specify the IP addresses you want to block: http { ... server { ... location /block/path { deny 192.168.1.1; deny 10.0.0.0/24; ... } } } You can use either the IP address or IP range format (CIDR notation) to specify the IP addresses you want to block.
  5. Save the configuration file and exit the text editor.
  6. Test the NGINX configuration to ensure it is valid: $ nginx -t
  7. If the configuration test is successful, reload or restart NGINX for the changes to take effect: $ systemctl reload nginx or $ service nginx restart

With these steps, NGINX will deny access to the specified IP addresses for the specified path or URL. If any requests come from these IP addresses, NGINX will return a forbidden (403) error.