ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    FTP Connection in the HAproxy

    IT Discussion
    reverse proxy haproxy ftp
    5
    12
    9.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Have you set pasv_address on the FTP machine?

      E 1 Reply Last reply Reply Quote 0
      • E
        Emsanator @scottalanmiller
        last edited by

        @scottalanmiller No, will I set it in configuration file of vsftpd on the FTP machine?

        scottalanmillerS 1 Reply Last reply Reply Quote 0
        • scottalanmillerS
          scottalanmiller @Emsanator
          last edited by

          @emsanator said in FTP Connection in the HAproxy:

          @scottalanmiller No, will I set it in configuration file of vsftpd on the FTP machine?

          Yes

          E 1 Reply Last reply Reply Quote 0
          • E
            Emsanator @scottalanmiller
            last edited by

            @scottalanmiller

            I added this lines in HAproxy conf. file:

             listen 
                bind <public IP>:21
                mode tcp  
                server web-second <local IP>:21 check
            

            Result:

            [root@rp ~]# sudo systemctl restart haproxy
            Job for haproxy.service failed because the control process exited with error code. See "systemctl status         haproxy.service" and "journalctl -xe" for details.
            [root@rp ~]# systemctl status haproxy.service
            ● haproxy.service - SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.
            Loaded: loaded (/etc/rc.d/init.d/haproxy; bad; vendor preset: disabled)
            Active: failed (Result: exit-code) since Thu 2018-04-05 19:48:57 UTC; 1s ago
            Docs: man:systemd-sysv-generator(8)
            Process: 15215 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
            Process: 15223 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=1/FAILURE)
            Main PID: 15197 (code=killed, signal=TERM)
            
            Apr 05 19:48:57 rp.domain.com systemd[1]: Starting SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments....
            Apr 05 19:48:57 rp.domain.com haproxy[15223]: [ALERT] 094/194857 (15227) : parsing [/etc/haproxy/haproxy.cfg:81] :     'listen' expects an <id> argument and
            Apr 05 19:48:57 rp.domain.com haproxy[15223]: optionally supports [addr1]:port1[-end1]{,[addr]:port[-end]}...
            Apr 05 19:48:57 rp.domain.com haproxy[15223]: [ALERT] 094/194857 (15227) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
            Apr 05 19:48:57 rp.domain.com haproxy[15223]: Errors found in configuration file, check it with 'haproxy check'.
            Apr 05 19:48:57 rp.domain.com systemd[1]: haproxy.service: control process exited, code=exited status=1
            Apr 05 19:48:57 rp.domain.com systemd[1]: Failed to start SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments..
            Apr 05 19:48:57 rp.domain.com systemd[1]: Unit haproxy.service entered failed state.
            Apr 05 19:48:57 rp.domain.com systemd[1]: haproxy.service failed.
            

            Where am I making mistakes?

            dbeatoD 1 Reply Last reply Reply Quote 0
            • dbeatoD
              dbeato @Emsanator
              last edited by dbeato

              @emsanator said in FTP Connection in the HAproxy:

              @scottalanmiller

              I added this lines in HAproxy conf. file:

               listen 
                bind <public IP>:21
                mode tcp  
                server web-second <local IP>:21 check
              

              Result:

              [root@rp ~]# sudo systemctl restart haproxy
              Job for haproxy.service failed because the control process exited with error code. See "systemctl status         haproxy.service" and "journalctl -xe" for details.
              [root@rp ~]# systemctl status haproxy.service
              ● haproxy.service - SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.
              Loaded: loaded (/etc/rc.d/init.d/haproxy; bad; vendor preset: disabled)
              Active: failed (Result: exit-code) since Thu 2018-04-05 19:48:57 UTC; 1s ago
              Docs: man:systemd-sysv-generator(8)
              Process: 15215 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
              Process: 15223 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=1/FAILURE)
              Main PID: 15197 (code=killed, signal=TERM)
              
              Apr 05 19:48:57 rp.domain.com systemd[1]: Starting SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments....
              Apr 05 19:48:57 rp.domain.com haproxy[15223]: [ALERT] 094/194857 (15227) : parsing [/etc/haproxy/haproxy.cfg:81] :     'listen' expects an <id> argument and
              Apr 05 19:48:57 rp.domain.com haproxy[15223]: optionally supports [addr1]:port1[-end1]{,[addr]:port[-end]}...
              Apr 05 19:48:57 rp.domain.com haproxy[15223]: [ALERT] 094/194857 (15227) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
              Apr 05 19:48:57 rp.domain.com haproxy[15223]: Errors found in configuration file, check it with 'haproxy check'.
              Apr 05 19:48:57 rp.domain.com systemd[1]: haproxy.service: control process exited, code=exited status=1
              Apr 05 19:48:57 rp.domain.com systemd[1]: Failed to start SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments..
              Apr 05 19:48:57 rp.domain.com systemd[1]: Unit haproxy.service entered failed state.
              Apr 05 19:48:57 rp.domain.com systemd[1]: haproxy.service failed.
              

              Where am I making mistakes?

              The configuration file has an issue, I am
              reviewing the configuration file. Before restarting running ‘haproxy check’ so you make sure it doesn’t fail on restart.

              1 Reply Last reply Reply Quote 0
              • M
                manxam
                last edited by

                You're missing a name declaration beside the listen in the last example that you posted.
                listen <my_service_here>
                and optionally the hostname and bind port:
                listen <my_service_here> localhost:8080

                E 1 Reply Last reply Reply Quote 0
                • E
                  Emsanator @manxam
                  last edited by

                  @manxam said in FTP Connection in the HAproxy:

                  You're missing a name declaration beside the listen in the last example that you posted.
                  listen <my_service_here>
                  and optionally the hostname and bind port:
                  listen <my_service_here> localhost:8080

                  I have one "listen" and for statistics.
                  Could you give an example for FTP listen?

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    manxam @Emsanator
                    last edited by

                    @emsanator : Check line 81 of your file. The error states that it couldn't find a declaration for listen on that line. (/etc/haproxy/haproxy.cfg:81)
                    I expect that you're missing "listen myftpserver" or similar.

                    E 1 Reply Last reply Reply Quote 1
                    • E
                      Emsanator @manxam
                      last edited by

                      @manxam

                       listen FTP  
                             bind *:21,:10000-10250
                             mode tcp 
                             server ftp01 192.168.1.4 check port 21
                             server ftp02 192.168.1.5 check port 21
                      

                      I do not get HAproxy error with this method

                      FileZilla Log:

                       Status:	Connecting to <Public IP>:21...
                       Status:	Connection established, waiting for welcome message...
                       Status:	Initializing TLS...
                       Status:	Verifying certificate...
                       Status:	TLS connection established.
                       Status:	Server does not support non-ASCII characters.
                       Status:	Logged in
                       Status:	Retrieving directory listing...
                       Status:	Server sent passive reply with unroutable address. Using server address instead.
                       Command:	MLSD
                       Error:	The data connection could not be established: ECONNREFUSED - Connection refused by server
                      

                      I tried every way in few days but I can not connect with FTP.

                      1 Reply Last reply Reply Quote 0
                      • M
                        manxam
                        last edited by

                        As @scottalanmiller mentioned above, you'll have to configure pasv on ftp and ensure your client is configured to use it as well.

                        within vsftpd.conf :

                        pasv_enable=YES
                        port_enable=YES
                        pasv_min_port=10000
                        pasv_max_port=10250
                        pasv_address=IP.OF.BOUND.INTERFACE
                        pasv_addr_resolve=NO
                        
                        1 Reply Last reply Reply Quote 1
                        • JaredBuschJ
                          JaredBusch
                          last edited by

                          https://serverfault.com/questions/663855/haproxy-for-load-balancing-vsftpd-servers

                          1 Reply Last reply Reply Quote 1
                          • 1 / 1
                          • First post
                            Last post