Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Nginx Module Development - get user ip     - 10 Nginx safety tips (Linux)

- Install FFmpeg compiling from source in Mac OS X environment (Linux)

- How to use Linux to download music from Grooveshark (Linux)

- AngularJS achieve picture upload feature (Programming)

- C ++ virtual functions Classic Insights (Programming)

- Defensive programming in PHP (Programming)

- Linux memory Cache Analysis (Linux)

- Some safety precautions of Linux servers (Linux)

- Taught you how to install Ubuntu Linux (Linux)

- When RHEL7 use fdisk partition, all partitions can not be used (Linux)

- How to cool down your Ubuntu system (Linux)

- Two strokes to improve development productivity Struts2 (Programming)

- The basic principle of pointers in C ++ (Programming)

- Apache Mina framework Practice (Programming)

- Linux System Tutorial: How to browse the Linux command line, weather forecast (Linux)

- MySQL 5.7.10 source code for the latest version of the installation process in detail (Database)

- How to update the Linux kernel to improve system performance (Linux)

- MySQL Tutorial: Using tpcc-mysql pressure measurement (Database)

- C language print various graphic (Programming)

- socket busy poll of Linux kernel 3.11 to avoid sleep switch (Linux)

  Nginx Module Development - get user ip
  Add Date : 2018-11-21      
  Nginx Module Development - get user ip

Core code:

if (r-> headers_in.x_real_ip! = NULL) {
         ngx_log_error (NGX_LOG_ERR, r-> connection-> log, 0, "% V", & r-> headers_in.x_real_ip-> value);
     } Else {
         sockaddr_in * sin = (sockaddr_in *) (r-> connection-> sockaddr);
         ngx_log_error (NGX_LOG_ERR, r-> connection-> log, 0, "% s", inet_ntoa (sin-> sin_addr));
Code testing so that

Code means: If Header has x-real-ip, it is treated as ip, ip otherwise get from the socket, there simply will be printed to the error log ip Lane

Where r is ngx_http_request_t pointer know nginx module to develop basic data structures will know this, if you do not know, please do understand separately

Tucao: I spent a morning time looking nginx module How to obtain ip, seemingly not much information on the Internet, just google a buddy said to go in the socket connection to get, a ready-made package nginx could not function?
- Install Visual Studio Code in Ubuntu (Linux)
- Reset CentOS / RHEL root account password 7 (Linux)
- How to build a container cluster (Server)
- Fedora 20 Installation and Configuration (Linux)
- Ubuntu download install and configure Plank Dock (Linux)
- To install file manager Nautilus 3.12.2 under ubuntu (Linux)
- Ubuntu 14.04 LTS 64-bit install GNS3 1.3.7 (Linux)
- Install Kali Linux via PXE network (Linux)
- Bitmap memory footprint of computing Android memory optimization (Linux)
- Introduction Linux namespace (Linux)
- Based kubernetes Construction Docker Cluster Management Comments (Server)
- Java NIO2: Buffer (Programming)
- Wireless LAN security solutions (Linux)
- Ubuntu compiler installation R Full Record (Linux)
- To build a private Docker registry (Server)
- Erase do with HTML5 Canvas and diffusion effect (Programming)
- Installation and use GAMIT / GLOBK Software (Linux)
- Workspace Go language and environment variables GOPATH (Linux)
- crontab cause CPU exception Analysis and Processing (Linux)
- Nginx Beginner Guide (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.