Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure haproxy port range to range one by one?

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

Here's the question, I can successfully login ftp service from ftp-client, but failed to execute ls command which output "connection refused" message. I guess the reason is port mapping from ftp-proxy-server to ftp-server is random. So when ftp-client get a reserved port(e.g. 20101), but ftp-proxy-server may map it to another port(e.g. 20109), which is not the port ftp-server assigned to ftp-client.

I am think of one solution that configured 100 listens, one listen to one port, but it's complex to write the configure file. Is'there a simply configuration option to map port one by one? Just like 10.0.1.1:20001 -> 172.126.1.1:20001, 10.0.1.1:20002 -> 172.126.1.1:20002.

Welcome any answer:)

like image 787
neil Avatar asked Nov 07 '14 05:11

neil


1 Answers

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
like image 185
kirrmann Avatar answered Nov 15 '22 08:11

kirrmann