优化pure-ftpd镜像

This commit is contained in:
KennyLee 2019-06-27 14:54:15 +08:00
parent 8ac05a2e9c
commit 4bebf93469
9 changed files with 65 additions and 79 deletions

4
nginx-pureftpd/.env Normal file
View File

@ -0,0 +1,4 @@
PUBLICHOST=localhost
FTP_USER_NAME=ftp
FTP_USER_PASS=ftp
FTP_USER_HOME=/usr/share/nginx/html

View File

@ -6,6 +6,8 @@ ftp镜像基于 [stilliard/pure-ftpd](https://hub.docker.com/r/stilliard/pure-ft
## 使用 ## 使用
> 注:如果想客户端支持`被动模式`,请修改`.env`配置文件中的`PUBLICHOST`变量;
1. 启动容器镜像 1. 启动容器镜像
执行命令 执行命令
@ -17,22 +19,10 @@ ftp镜像基于 [stilliard/pure-ftpd](https://hub.docker.com/r/stilliard/pure-ft
2. Ftp配置 2. Ftp配置
``` ```
# 进入ftp容器 username: ftp
docker exec -it ftpd_server /bin/bash password: ftp
# 创建ftp用户并且制定根目录
pure-pw useradd ftp -u ftpuser -d /usr/share/nginx/html
# 创建库
pure-pw mkdb
``` ```
其中,用户名为 `ftp` ,密码输入后,重启服务
```
docker restart ftpd_server
```
> 注实测对ftp客户端兼容性不太好并且连接时不要选择被动模式
3. Nginx 3. Nginx
默认是不开放文档列表功能,如果目录中没索引文件(index.html),会报 `403 Forbidden` 默认是不开放文档列表功能,如果目录中没索引文件(index.html),会报 `403 Forbidden`

View File

@ -1,4 +1,4 @@
version: '2.4' version: '2'
services: services:
web: web:
image: registry.cn-hangzhou.aliyuncs.com/kennylee/nginx:alpine-1.13 image: registry.cn-hangzhou.aliyuncs.com/kennylee/nginx:alpine-1.13
@ -7,27 +7,32 @@ services:
- "80:80" - "80:80"
volumes: volumes:
- ./data/html/:/usr/share/nginx/html - ./data/html/:/usr/share/nginx/html
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf/conf.d/:/etc/nginx/conf.d/ - ./nginx/config/conf.d/:/etc/nginx/conf.d/
restart: on-failure restart: on-failure
logging: logging:
driver: 'json-file' driver: 'json-file'
options: options:
max-size: '12m' max-size: '12m'
max-file: '5' max-file: '5'
ftp: ftpd:
build: ./ftp image: registry.cn-hangzhou.aliyuncs.com/kennylee/pure-ftpd:stretch-without-user
container_name: "ftpd_server" container_name: "ftpd_server"
ports: ports:
- "21:21" - "21:21"
- "30000-30009:30000-30009" - "30000-30059:30000-30059"
volumes: volumes:
- ./data/html/:/usr/share/nginx/html - ./data/html/:${FTP_USER_HOME}
- ./data/pure-ftpd:/etc/pure-ftpd - ./data/pure-ftpd/passwd:/etc/pure-ftpd/passwd
restart: on-failure
privileged: true
environment: environment:
- TZ=Asia/Shanghai PUBLICHOST: ${PUBLICHOST}
FTP_USER_NAME: ${FTP_USER_NAME}
FTP_USER_PASS: ${FTP_USER_PASS}
FTP_USER_HOME: ${FTP_USER_HOME}
FTP_MAX_CLIENTS: 30
FTP_MAX_CONNECTIONS: 10
ADDED_FLAGS: "-p 30000:30059 -9 utf8"
restart: on-failure
logging: logging:
driver: 'json-file' driver: 'json-file'
options: options:

View File

@ -1,20 +0,0 @@
# Pure ftp-Server
#
# VERSION 0.0.1
# Base image: https://github.com/stilliard/docker-pure-ftpd
# Command format: Instruction [arguments command] ..
# 第一行必须指定基于的基础镜像
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/pure-ftpd:stretch-without-user
# 维护者信息
MAINTAINER kennylee26 <kennylee26@gmail.com>
#add base user info
COPY run.sh /run.sh
RUN chmod +x /*.sh
# Define default command.
EXPOSE 21/tcp 30000-30009
CMD ["/run.sh"]

View File

@ -1,3 +0,0 @@
#!/bin/bash
bash -c '/usr/sbin/pure-ftpd -c 30 -C 5 -9 utf8 -l puredb:/etc/pure-ftpd/pureftpd.pdb -x -E -j -R'

3
pure-ftpd/.env Normal file
View File

@ -0,0 +1,3 @@
PUBLICHOST=localhost
FTP_USER_NAME=ftp
FTP_USER_PASS=ftp

View File

@ -3,14 +3,3 @@ FROM registry.cn-hangzhou.aliyuncs.com/kennylee/pure-ftpd:stretch-without-user
MAINTAINER kennylee26 <kennylee26@gmail.com> MAINTAINER kennylee26 <kennylee26@gmail.com>
ENV PUBLICHOST localhost
ENV FTP_USER_HOME=/home/ftpusers \
FTP_USER_NAME=ftp \
FTP_USER_PASS=ftp
COPY ./create_user.sh /create_user.sh
RUN chmod +x /create_user.sh
RUN /create_user.sh
# Define default command.
CMD /run.sh --maxclientsnumber 30 --maxclientsperip 10 --clientcharset utf8 --login puredb:/etc/pure-ftpd/pureftpd.pdb --noanonymous -j -R -P $PUBLICHOST --passiveportrange 30000:30059

View File

@ -1,31 +1,43 @@
ftp镜像-使用pureftp # ftp镜像-使用pureftp
===== ## 说明
默认ftp用户信息: 基于 [stilliard/pure-ftpd](https://github.com/stilliard/docker-pure-ftpd) 镜像;
docker-compose启动后默认ftp用户信息:
``` ```
username: ftp username: ftp
password: ftp password: ftp
``` ```
详细参见 Dockerfile 文件 > 注:如果想客户端支持`被动模式`,注意启动镜像的时候配置 `PUBLICHOST` 环境变量;
数据目录默认是 ```/home/ftpusers``` 和 ```/etc/pure-ftpd``` 前者是ftp用户的基础目录后者是ftp的配置文件目录。 ### pure-ftpd配置说明
命令参考 常用配置
* build | 参数 | 说明 |
docker build -t kennylee26/pureftpd . | --- | --- |
* run | -c --maxclientsnumber | 最大连接数;注意端口数量;<br />最大连接数最大1 -最小)/ 2<br />如果端口太少,最大连接数也是无用的;|
docker run -d --net=host --name=pureftpd kennylee26/pureftpd | -C --maxclientsperip | 每个ip连接数量 |
| -d --verboselog | 记录日志 |
| -e --anonymousonly | 仅支持匿名登录访问 |
| -E --noanonymous | 不允许匿名用户连接 |
| -j --createhomedir | 如果虚拟用户的目录不存在则自动创建 |
| -R --nochmod | 不接受 CHMOD 命令。用户不能更改他们文件的属性。 |
| -P --forcepassiveip <ip address> | 强制指定返回IP被动模式下好用<br />不然会返回内网IP给客户端客户端可能不能访问<br />这是可以手动指定外网IP |
| -l --login | 用户验证数据文件 |
| -p --passiveportrange | 被动模式端口范围 |
| -9 --clientcharset | 默认编码 |
| -x --prohibitdotfileswrite | 不能删除/写入隐藏文件 |
注意事项: 详见http://download.pureftpd.org/pub/pure-ftpd/doc/README
1. 如果有windows用户必须设置net=host才能访问。原因未知.... ## 镜像版本
-------- 镜像内已不内置创建用户请启动镜像的时候传入FTP_USER_NAME等变量具体参见[stilliard/pure-ftpd](https://github.com/stilliard/docker-pure-ftpd)
FTP配置信息参见http://download.pureftpd.org/pub/pure-ftpd/doc/README
* stretch-without-user: stilliard/pure-ftpd的镜像修改本地源安装基础软件和本地时区设置
* latest: 基于 `stretch-without-user` 版本一致;

View File

@ -1,4 +1,4 @@
version: '2.4' version: '2'
services: services:
ftpd: ftpd:
@ -7,12 +7,18 @@ services:
ports: ports:
- "30000-30059:30000-30059" - "30000-30059:30000-30059"
- "21:21" - "21:21"
environment:
- PUBLICHOST=localhost
volumes: volumes:
- ./data/files/:/home/ftpusers/ftp/ - ./data/files/:/home/ftpusers/
- ./data/pure-ftpd/passwd:/etc/pure-ftpd/passwd
environment:
PUBLICHOST: ${PUBLICHOST}
FTP_USER_NAME: ${FTP_USER_NAME}
FTP_USER_PASS: ${FTP_USER_PASS}
FTP_USER_HOME: /home/ftpusers/${FTP_USER_NAME}
FTP_MAX_CLIENTS: 30
FTP_MAX_CONNECTIONS: 10
ADDED_FLAGS: "-p 30000:30059 -9 utf8"
restart: on-failure restart: on-failure
command: /run.sh --maxclientsnumber 30 --maxclientsperip 30 --clientcharset utf8 --login puredb:/etc/pure-ftpd/pureftpd.pdb --noanonymous -j -R --passiveportrange 30000:30059
logging: logging:
driver: 'json-file' driver: 'json-file'
options: options: