Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Nginx Module Development - get user ip     - Customize the 404 error page Nginx (Server)

- Build and verify MongoDB3.0.7 version (shard + replica) Cluster (Database)

- pga_aggregate_target and _pga_max_size can not use absolute limit actual PGA (Database)

- Android Studio quick overview of Gradle (Programming)

- Ubuntu 15.10 How to install TeamViewer 11 (Linux)

- OpenCV 3.0 + Python 2.7 installation and testing under Ubuntu 14.04 (Linux)

- LMMS 1.03 install on Ubuntu 14.04 (Linux)

- Android LayoutInflater source parsing (Programming)

- Installation in lxml Python module (Linux)

- Getting Started with Linux system to learn: how to configure a static IP address for CentOS7 (Linux)

- MongoDB3.0.x version of the user authorization profile (stand-alone environment) (Database)

- Python programmers most often committed ten errors (Programming)

- Linux more command Detailed (Linux)

- Linux rename command usage in learning to modify the file name (Linux)

- DM9000 timing settings (Programming)

- Linux landing problem (Linux)

- Linux cron job (crontab) Examples (Linux)

- Switching Virtual Machine + Ubuntu graphical interface and terminal interface (Linux)

- Getting CentOS Learning Notes (Linux)

- Shell scripts get a snapshot of the page and generates thumbnails (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?
     
         
         
         
  More:      
 
- The difference between IPython and Python (Linux)
- CoreCLR compiled in Linux CentOS (Linux)
- HTTPS and SSH and use the difference between the way: Git User's Manual (Linux)
- linux network security experience (Linux)
- CentOS install Redis (Database)
- Ubuntu 32 compile Android 4.0.4 Problems (Linux)
- Ora-00020: maximum number of processes (500) exceeded (Database)
- Caffe install under Ubuntu 14.04 64bit (Linux)
- Oracle 12c of the auto-increment Identity Columns (Database)
- Tab set to four spaces in Vim (Linux)
- Shell scripts to copy all directories under the current directory of a certain type of file to the same directory (Linux)
- How to use the TF / SD card making Exynos 4412 u-boot boot disk in Mac (Linux)
- Flask deploy applications using Nginx on Ubuntu (Server)
- C ++ implementation of the list of basic operations and test cases (Programming)
- CentOS RedHat YUM Source Extensions Supplement (including 32-bit, 64-bit) (Linux)
- Sublime Text Add instructions to insert the current time zone (Linux)
- Spring-depth understanding of the various annotations (Programming)
- Android memory optimization of the optimal load Bitmap (Linux)
- Java annotations entry automatically generates SQL statements (Programming)
- The official release method to upgrade to Ubuntu 15.04 (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.