nginx stream_realip_module
时间: 2024-01-03 09:03:40 浏览: 26
The nginx stream_realip_module is a module that allows the real IP address of a client to be passed through to the backend server. This is useful in cases where the client IP address is masked or hidden by a proxy or load balancer.
When a client makes a request to an nginx server through a proxy or load balancer, the IP address that is recorded by the server is the IP address of the proxy or load balancer, not the IP address of the client. This can be problematic for some applications that rely on the client IP address for security or logging purposes.
The stream_realip_module allows nginx to replace the IP address of the proxy or load balancer with the real IP address of the client. This is done by examining the X-Forwarded-For header in the incoming request and using the last IP address in the header as the client's real IP address.
To use the stream_realip_module, it must first be enabled in nginx by including the module in the configure command when building nginx. Once enabled, the module can be configured in the nginx configuration file to specify the IP address or subnet of the trusted proxy or load balancer. The real IP address of the client will only be passed through if the incoming request is from a trusted IP address.
Overall, the stream_realip_module is a useful tool for ensuring that the real IP address of a client is passed through to the backend server, improving security and logging capabilities.