docker - 在 Azure Kubernetes 中托管的 FTP 服务器

标签 docker nat azure-aks ftp-server vsftpd

我在 Azure Kubernetes pod 中托管一个 FTP 服务器,基本上是 vsftpd 服务器。我已经使用负载平衡器类型的服务公开了它。我也已将所有暴露的端口转发给服务。我仍然无法以被动模式连接到服务器。

我启用了被动模式。由于 Azure Kubernetes 在 NAT 之后,我还明确提供了 pasv_address 作为暴露的负载均衡器服务的外部 ip。我还尝试使用 xinetd 而不是独立运行 FTP 服务器,但它没有用。 我在某处找到了一个解决方案,可以在 vsftpd.conf 中添加它 seccomp_sandbox=否 但它不起作用。我尝试使用 Windows PowerShell 进行连接。还有 FileZilla 和 wsftp。我还在我的机器上禁用了防火墙。

我还尝试使用部署它的同一个 pod 连接 FTP 服务器,并且我能够传输数据。它将使用主动模式。我还尝试使用 PASSIVE 模式从同一集群中的不同 pod 连接到 FTP 服务器,我能够做到这一点,甚至传输了一个文件。但是在集群外部使用我的本地机器或任何其他 FTP 客户端,我无法在 FTP 服务器上打开数据通道。

我已经在docker容器本地部署了相同配置的FTP服务器,但仍然无法在FTP服务器上打开数据通道。

这是我在 FTP 服务器中使用的 vsftpd.conf

listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
allow_writeable_chroot=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
user_sub_token=$USER
local_root=/home/$USER/ftp
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30009
pasv_promiscuous=YES
dirlist_enable=YES
download_enable=YES
use_sendfile=NO
pasv_address=x.x.x.x # Load balancer External IP
seccomp_sandbox=NO

Here is the deployment.yaml to deploy that in Kubernetes. Note i am also deploying mssql server in the same pod and i am able to access it.
---
apiVersion: v1
kind: Service
metadata:
  name: ipldb-mssql-deployment
spec:
  selector:
    app: ipldb-mssql
  ports:
    - { port: 1433, targetPort: 1433, name: tcp }
    - { port: 21, targetPort: 21, name: ftp }
    - { port: 30000, targetPort: 30000, name: pasv1 }
    - { port: 30001, targetPort: 30001, name: pasv2 }
    - { port: 30002, targetPort: 30002, name: pasv3 }
    - { port: 30003, targetPort: 30003, name: pasv4 }
    - { port: 30004, targetPort: 30004, name: pasv5 }
    - { port: 30005, targetPort: 30005, name: pasv6 }
    - { port: 30006, targetPort: 30006, name: pasv7 }
    - { port: 30007, targetPort: 30007, name: pasv8 }
    - { port: 30008, targetPort: 30008, name: pasv9 }
    - { port: 30009, targetPort: 30009, name: pasv10 }
  type: LoadBalancer
---
apiVersion: apps/v1beta1
kind: Deployment
metadata: 
  name: ipldb-mssql-deployment
spec: 
  replicas: 1
  template: 
    metadata: 
      labels: 
        app: ipldb-mssql
    spec: 
      containers: 
        - 
          env: 
            - 
              name: MSSQL_PID
              value: Developer
            - 
              name: ACCEPT_EULA
              value: "Y"
            - 
              name: MSSQL_SA_PASSWORD
              value: pass
          image: "image"
          name: ipldb-mssql-filestorage
          ports: 
            - 
              containerPort: 1433
            - 
              containerPort: 21
            - 
              containerPort: 30000
            - 
              containerPort: 30001
            - 
              containerPort: 30002
            - 
              containerPort: 30003
            - 
              containerPort: 30004
            - 
              containerPort: 30005
            - 
              containerPort: 30006
            - 
              containerPort: 30007
            - 
              containerPort: 30008
            - 
              containerPort: 30009
      imagePullSecrets: 
        - 
          name: myPullSeceret

我需要在 Kubernetes 上运行这个 FTP 服务器,而不需要客户端打开不必要的端口。但是我使用的客户端给我错误

227 Entering Passive Mode (x,x,x,x,x,x). connecting data channel to x.x.x.x:x,x(x) Failed to connect data channel to x.x.x.x:x,x(x) PORT x,x,x,x,x,x 500 Illegal PORT command. Port failed 500 Illegal PORT command.

最佳答案

我能够弄清楚这个问题。如果有人需要这个答案,我会做出回应。 我将 externalTrafficPolicy: Cluster 更改为 externalTrafficPolicy: Local 负载均衡器服务。

关于docker - 在 Azure Kubernetes 中托管的 FTP 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57321369/

相关文章:

azure - 使用 Terraform 将 AKS 群集附加到现有 VNET

linux - 如何让我的 docker 在指定的 linux 内核版本上运行?

docker - 如何使用Docker Dockerfile创建启用PostgreSQL图像的PostGIS

nat - gethostbyaddr() 应该在 NAT 环境中工作吗?

c# - 如何进行端口转发?

webrtc - 我们可以使用公共(public) STUN 服务器来创建我们的商业应用程序吗?

等待条件时terraform helm释放超时

windows - OSError : Can not read file in context:\\?\C :\project\. gradle\6.6.1\executionHistory\executionHistory.lock

docker - Travis-CI:docker 镜像作为构建环境

c# - AKS集群Pod Kube配置位置