Closed PhDLeToanThang closed 6 months ago
You have to remove the port range from the server definition. The haproxy documentation shows that the same port from the source is used for the destination.
listen ftp-proxy-server 10.0.1.1:20100-20199 mode tcp server ftp-server 172.126.1.1
1
For haproxy 1.5 on centos,
listen web *:8080-8090 mode tcp server worker1 10.0.0.1 server worker2 10.0.0.2 For haproxy 1.7 on debian,
listen web bind *:8080-8090 mode tcp server worker1 10.0.0.1 server worker2 10.0.0.2
Certainly! To configure HAProxy for an FTP server service with a port range, follow these steps:
Edit the HAProxy configuration file (/etc/haproxy/haproxy.cfg
):
Add the following lines to configure the FTP service:
listen FTP_Default *:21
server ftp01 192.168.122.152 check port 21 inter 10s rise 1 fall 2
listen FTP_Range *:10000-10250
server ftp01 192.168.122.152 check port 21 inter 10s rise 1 fall 2
192.168.122.152
with the actual IP address of your FTP server¹.Configure the passive FTP port range on the FTP server:
50000-500[1](https://serverfault.com/questions/441721/ftp-through-haproxy)0
or a larger range. Be cautious to limit the port range to prevent file descriptor exhaustion².Update the HAProxy frontend section:
frontend ftp_frontend
mode tcp
bind *:[2](https://www.haproxy.com/documentation/haproxy-configuration-tutorials/load-balancing/passive-ftp/)1
default_backend ftp_backend
Remember to adjust the IP addresses, port ranges, and other settings according to your specific environment. If you have any further questions, feel free to ask! 😊
Source: Conversation with Bing, 23/4/2024 (1) FTP through HAProxy - Server Fault. https://serverfault.com/questions/441721/ftp-through-haproxy. (2) Passive FTP | HAProxy config tutorials. https://www.haproxy.com/documentation/haproxy-configuration-tutorials/load-balancing/passive-ftp/. (3) Frontends | HAProxy config tutorials. https://www.haproxy.com/documentation/haproxy-configuration-tutorials/core-concepts/frontends/. (4) How to configure haproxy port range to range one by one?. https://stackoverflow.com/questions/26794547/how-to-configure-haproxy-port-range-to-range-one-by-one. (5) Binding TCP port ranges to backend port ranges - Help! - HAProxy community. https://discourse.haproxy.org/t/binding-tcp-port-ranges-to-backend-port-ranges/6893.
Sửa lại Sample FTP with Haproxy 2.9:
####################################3
frontend ftp-proxy-server bind *:21 mode tcp default_backend ftp-backend
backend ftp-backend mode tcp server ftp-server 172.126.1.1:21
frontend ftp-data-proxy bind *:20001 mode tcp default_backend ftp-data-backend-20001
backend ftp-data-backend-20001 mode tcp balance source server ftp-data-server 172.126.1.1:20001
frontend ftp-data-proxy-20100 bind *:20100 mode tcp default_backend ftp-data-backend-20100
backend ftp-data-backend-20100 mode tcp balance source server ftp-data-server 172.126.1.1:20100
haproxy /sample_FTP_haproxy.cfg
7
I want to use haproxy to deploy one ftp proxy server. Here's scene:
ftp client <---> ftp-proxy-server(ip:10.0.1.1) <---> ftp-server(ip:172.126.1.1)
ftp server listen on port 21 for control command, data port range [20100-20199]
I had haproxy config on ftp-proxy-server:
listen ftp-proxy-server 10.0.1.1:21 mode tcp server ftp-server 172.126.1.1:21
listen ftp-proxy-server 10.0.1.1:20100-20199 mode tcp server ftp-server 172.126.1.1:20100-20199