Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Nginx Module Development - get user ip     - Source install Python3.4 on CentOS (Linux)

- Linux5 install MySQL 5.6 (RPM mode) (Database)

- The difference between VMware virtual machine network mode (Linux)

- MySQL separation Amoeba achieve literacy (Database)

- Oracle Shared Server Configuration (Database)

- The signature can not be verified under Debian (Linux)

- Linux Getting Started tutorial: Ubuntu 14.04 in the installation Sogou Pinyin (Linux)

- Linux System Getting Started Learning: Disable HTTP forwarding wget in (Linux)

- Windows 7 hard disk to install Ubuntu 15.04 (Linux)

- Overall Physical Migration of Oracle Database with (Database)

- JIRA 3.6.2 Upgrade from older version to the new version 6.0.8 (Linux)

- CentOS 6 Install Linux kernel source (Linux)

- Django how to generate content in non-HTML formats (Programming)

- Detailed installation of CentOS 6.x (Linux)

- Zabbix API and PHP configuration (Server)

- Linux firewall security (Linux)

- Why learn and use C language (Programming)

- Create the best introductory tutorial REST API (Linux)

- Acting on JavaScript events (Programming)

- C ++ Fundamentals study notes (Programming)

 
         
  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 headers for the current running kernel were not found when VirtualBox installation enhancements (Linux)
- How to set the default Fedora from the command line (Linux)
- Spring Data JPA @EnableJpaRepositories configuration in detail (Programming)
- Distributed transaction management Spring declarative transactions (Programming)
- How to Debian Linux the default Python version switch to alternative version (Linux)
- RHEL5 multipath configuration (Linux)
- Linux / CentOS 7.0 installation and configuration under Tomcat 8.0 (Server)
- Linux create and delete user step (Linux)
- Graphical development environment to build Android under Ubuntu 11.04 (Linux)
- Construction Spark source and application development environment (Server)
- Sorting algorithm of dichotomy (binary) insertion sort algorithm (Programming)
- Talking about modern programming language syntax and standard library tightly bound phenomenon (Programming)
- Specifies the open ports of the SUSE firewall settings (Linux)
- Linux NFS service fixed ports and firewall configuration (Linux)
- How to install Ubuntu applications Device 7 (Linux)
- Using Maven to download Spring (Linux)
- Ubuntu download install and configure Plank Dock (Linux)
- In addition to wget and curl, what better alternatives (Linux)
- Java executable file to read information from a database copy (Programming)
- To share some very useful Vim command (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.