Welcome! Log In Create A New Profile

Advanced

Getting client ip without proxy_protocol or condition for proxy_protocol in http host

Posted by trider 
Getting client ip without proxy_protocol or condition for proxy_protocol in http host
November 24, 2020 12:13PM
Hello! I have servers with nginx in stream configuration that proxy requests to servers with nginx in http configuration:
[nginx stream] ---> [nginx http]
On servers with nginx http, I need real IP of client, which is taken from TCP session, which is established by client with nginx stream. It looks simple and guide https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/ would help me. But this is not the case!
The fact is that if I enable proxy_protocol on the backend (nginx http), it will not be able to process a simple HTTP request and I will get a response '400 Bad Request'. My virtual http host must work in universal mode, both using proxy_protocol and without it. How can I do this? The option with some intermediate HTTP host on my http nginx that uses proxy_protocol and proxies HTTP requests to simple HTTP host without proxy_protocol will not work for me. Because any worker generates TCP sessions using some unprivileged ports, of which there are few left on my server. If I can't configure http host to paralle work with and without proxy_protocol, then I'm interested in delivering client IP without proxy_protocol.
How do I deliver client IP to backend(nginx http) without enabling proxy_porotocol on both nginx stream and nginx http?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready