Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Nginx Module Development - get user ip     - Ubuntu install Eclipse can not find JAVA_HOME problem (Linux)

- How to upgrade Docker 1.6 on Fedora / CentOS (Server)

- Java proxy mode (Programming)

- ORA-01157 & ORA-01110 Troubleshooting (Database)

- Linux Shell introduces (Linux)

- To compile and install OpenCV-2.3.1 FFmpeg-2.1.2 under CentOS (Linux)

- Linux virtual machines to solve end MySQL database can not remote access (Database)

- Ubuntu 14.04 VirtualBox can not start solution (Linux)

- Linux RPM default installation path (Linux)

- Not safe procedure under Linux (Linux)

- Root of AVL Tree- achieve balanced search trees AVL tree (Programming)

- Linux atomic operations and synchronization mechanisms (Programming)

- Configuring s3c-linux- appears Unable to find the QT3 installation (Linux)

- How to use the on-screen keyboard in Linux (Linux)

- U disk to install Windows and Ubuntu 15.04 dual system (Programming)

- Android development environment to build under Fedora 13 (Linux)

- Android Launcher3 Application List Modify a transparent background (Linux)

- PostgreSQL export table structure information (Database)

- Compile and install LNMP under CentOS 6.5 (Server)

- MongoDB replication instance (Database)

  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?
- The callback function used in C ++ (Programming)
- Nginx server load balancing dual-system availability (Server)
- Intel Graphics Installer installation on Ubuntu 15.10 (Linux)
- JDK installation under CentOS (Linux)
- Android Action Compendium (Programming)
- Android 5.1 OTA package compilation error (Programming)
- Axel install plug under CentOS 5/6 acceleration yum downloads (Linux)
- Hibernate4 The Hello World (basic environmental structures) (Programming)
- Oracle Bug caused by the collection of AWR Snapshot fault (Database)
- Debian (Wheezy) were installed wxPython GUI development (Linux)
- Install Python 3.3.4 under CentOS 6.4 (Linux)
- How to use the ftp tool to transfer files between Windows and Linux (Linux)
- Linux Crontab Timing task command Detailed (Linux)
- Swift string common method (Programming)
- Linux System Tutorial: Ubuntu on the desktop is disabled by default keyring to unlock tips (Linux)
- Linux 0.12 kernel and modern kernels difference in memory management (Linux)
- Create the container and run the application Docker (Server)
- How to identify memory leaks in Java (Programming)
- Nodejs nano library to handle couchdb: need a timeout (Database)
- C ++ Supplements - locates the new expression (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.