HAproxy to NGINX – mode tcp configuration – ERR_CONNECTION_CLOSED
There is a website on a server with nginx.
I need to hide the real IP address of the website, so I decided to configure access to it via a proxy server with HAproxy.
On the server with the website, I need to see the real IP addresses, not the proxy, so I wanted to specify server real-server REAL_SERVER_IP:443 send-proxy in the HAproxy configuration and listen 443 ssl proxy_protocol in the nginx configuration. But then a problem arose: when specifying “proxy_protocol” nginx will only be able to accept requests from the proxy server and will not be accessible directly, but I cannot allow downtime while the DNS is updating the A record from the old IP to the proxy server IP.
So I decided that HAproxy would listen to port 443 and redirect it to nginx on port 444, and in nginx I would create two ports, 443 and 444. This way, the site would be accessible both directly and through proxy during the transition period.
But for some reason, the site does not open through the proxy – ERR_CONNECTION_CLOSED Please tell me what I missed or did wrong?
nginx conf:
listen 443 ssl;
listen [::]:443 ssl;
listen 444 ssl proxy_protocol;
listen [::]:444 ssl proxy_protocol;
real_ip_header proxy_protocol;
set_real_ip_from PROXY_SERVER_IP;
HAproxy conf:
frontend https_in
bind *:443
mode tcp
default_backend https_backend
backend https_backend
mode tcp
option tcplog
server realserver SERVER_REAL_IP:444 send-proxy
Read more here: Source link
