[pure-ftpd] Issues with GCP load balancing multi instance

Luca Gervasi <[email protected]> Thu, 27 Feb 2020 17:02:50 +0100
Newsgroups gmane.network.pureftpd.user
Message-ID <CAPJi5KPszD2rCXMqUu_f+1vE-0TLiBi+x1nUR_G5D9VXrh+V_A@mail.gmail.com>
--000000000000fb50ef059f90da2d
Content-Type: text/plain; charset="UTF-8"

Hi,
i'm trying to configure pure-ftpd behind a load balancer on GCP. In my
setup, i want to configure load balancing on port 21, having 2 instances
with its own public ip to be used for passive ports.
So: you connect to a common address <mylb.organisation>:21, it
redistributes to the working instances, each of them then PASV to its own
ip and the ephemeral port configured. This is the configuration example:
On instance1:
PassivePortRange          60000 61000
ForcePassiveIP            <instance1IP>

On instance2:
PassivePortRange          60000 61000
ForcePassiveIP            <instance1IP>

And so far this works:
Status: Logged in
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is your current location
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (InstanceIP1,234,246)

Problem is that when it goes bind(), it uses the (and how the hell did it
get the ip?) load balancer ip:
2251 bind(9, {sa_family=AF_INET, sin_port=htons(60553),
sin_addr=inet_addr("<LOADBALANCERIP>")}, 16) = 0
12251 alarm(120)                        = 240
12251 listen(9, 8                     = 0
12251 sendto(3, "<95>Feb 27 14:44:05 pure-ftpd[12251]: ([email protected])
[DEBUG] 227 Entering Passive Mode (<InstanceIP>,236,137)", 119,
MSG_NOSIGNAL, NULL, 0) = 119
12251 write(6, "227 Entering Passive Mode (<InstanceIP>,236,137)\r\n", 50)
= 50

So when the client tries to connect to the server, it gets a RST after the
syn, even if the port is actually listening correctly.

Is there a way to have pure-ftpd binding to 0.0.0.0 or its own ip during
the passive binding?

Thanks!

Luca

--000000000000fb50ef059f90da2d--