mirror of
https://gitee.com/kennylee/docker.git
synced 2024-11-29 18:38:34 +08:00
优化pure-ftpd镜像
This commit is contained in:
parent
8ac05a2e9c
commit
4bebf93469
4
nginx-pureftpd/.env
Normal file
4
nginx-pureftpd/.env
Normal file
@ -0,0 +1,4 @@
|
||||
PUBLICHOST=localhost
|
||||
FTP_USER_NAME=ftp
|
||||
FTP_USER_PASS=ftp
|
||||
FTP_USER_HOME=/usr/share/nginx/html
|
@ -6,6 +6,8 @@ ftp镜像基于 [stilliard/pure-ftpd](https://hub.docker.com/r/stilliard/pure-ft
|
||||
|
||||
## 使用
|
||||
|
||||
> 注:如果想客户端支持`被动模式`,请修改`.env`配置文件中的`PUBLICHOST`变量;
|
||||
|
||||
1. 启动容器镜像
|
||||
|
||||
执行命令
|
||||
@ -17,22 +19,10 @@ ftp镜像基于 [stilliard/pure-ftpd](https://hub.docker.com/r/stilliard/pure-ft
|
||||
2. Ftp配置
|
||||
|
||||
```
|
||||
# 进入ftp容器
|
||||
docker exec -it ftpd_server /bin/bash
|
||||
# 创建ftp用户,并且制定根目录
|
||||
pure-pw useradd ftp -u ftpuser -d /usr/share/nginx/html
|
||||
# 创建库
|
||||
pure-pw mkdb
|
||||
username: ftp
|
||||
password: ftp
|
||||
```
|
||||
|
||||
其中,用户名为 `ftp` ,密码输入后,重启服务
|
||||
|
||||
```
|
||||
docker restart ftpd_server
|
||||
```
|
||||
|
||||
> 注:实测对ftp客户端兼容性不太好,并且连接时不要选择被动模式!
|
||||
|
||||
3. Nginx
|
||||
|
||||
默认是不开放文档列表功能,如果目录中没索引文件(index.html),会报 `403 Forbidden`;
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2.4'
|
||||
version: '2'
|
||||
services:
|
||||
web:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/kennylee/nginx:alpine-1.13
|
||||
@ -7,27 +7,32 @@ services:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./data/html/:/usr/share/nginx/html
|
||||
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./nginx/conf/conf.d/:/etc/nginx/conf.d/
|
||||
- ./nginx/config/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./nginx/config/conf.d/:/etc/nginx/conf.d/
|
||||
restart: on-failure
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
max-size: '12m'
|
||||
max-file: '5'
|
||||
ftp:
|
||||
build: ./ftp
|
||||
ftpd:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/kennylee/pure-ftpd:stretch-without-user
|
||||
container_name: "ftpd_server"
|
||||
ports:
|
||||
- "21:21"
|
||||
- "30000-30009:30000-30009"
|
||||
- "30000-30059:30000-30059"
|
||||
volumes:
|
||||
- ./data/html/:/usr/share/nginx/html
|
||||
- ./data/pure-ftpd:/etc/pure-ftpd
|
||||
restart: on-failure
|
||||
privileged: true
|
||||
- ./data/html/:${FTP_USER_HOME}
|
||||
- ./data/pure-ftpd/passwd:/etc/pure-ftpd/passwd
|
||||
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:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
|
@ -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"]
|
@ -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
3
pure-ftpd/.env
Normal file
@ -0,0 +1,3 @@
|
||||
PUBLICHOST=localhost
|
||||
FTP_USER_NAME=ftp
|
||||
FTP_USER_PASS=ftp
|
@ -3,14 +3,3 @@ FROM registry.cn-hangzhou.aliyuncs.com/kennylee/pure-ftpd:stretch-without-user
|
||||
|
||||
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
|
||||
|
@ -1,31 +1,43 @@
|
||||
ftp镜像-使用pureftp
|
||||
# ftp镜像-使用pureftp
|
||||
|
||||
=====
|
||||
## 说明
|
||||
|
||||
默认ftp用户信息:
|
||||
基于 [stilliard/pure-ftpd](https://github.com/stilliard/docker-pure-ftpd) 镜像;
|
||||
|
||||
docker-compose启动后,默认ftp用户信息:
|
||||
|
||||
```
|
||||
username: ftp
|
||||
password: ftp
|
||||
```
|
||||
|
||||
详细参见 Dockerfile 文件
|
||||
> 注:如果想客户端支持`被动模式`,注意启动镜像的时候配置 `PUBLICHOST` 环境变量;
|
||||
|
||||
数据目录默认是 ```/home/ftpusers``` 和 ```/etc/pure-ftpd``` ,前者是ftp用户的基础目录,后者是ftp的配置文件目录。
|
||||
### pure-ftpd配置说明
|
||||
|
||||
命令参考
|
||||
常用配置
|
||||
|
||||
* build
|
||||
docker build -t kennylee26/pureftpd .
|
||||
* run
|
||||
docker run -d --net=host --name=pureftpd kennylee26/pureftpd
|
||||
|
||||
注意事项:
|
||||
| 参数 | 说明 |
|
||||
| --- | --- |
|
||||
| -c --maxclientsnumber | 最大连接数;注意端口数量;<br />最大连接数=(最大+1 -最小)/ 2;<br />如果端口太少,最大连接数也是无用的;|
|
||||
| -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 | 不能删除/写入隐藏文件 |
|
||||
|
||||
1. 如果有windows用户,必须设置net=host才能访问。原因未知....
|
||||
详见:http://download.pureftpd.org/pub/pure-ftpd/doc/README
|
||||
|
||||
--------
|
||||
## 镜像版本
|
||||
|
||||
FTP配置信息,参见:http://download.pureftpd.org/pub/pure-ftpd/doc/README
|
||||
镜像内已不内置创建用户,请启动镜像的时候传入FTP_USER_NAME等变量,具体参见[stilliard/pure-ftpd](https://github.com/stilliard/docker-pure-ftpd)
|
||||
|
||||
* stretch-without-user: stilliard/pure-ftpd的镜像,修改本地源,安装基础软件和本地时区设置;
|
||||
* latest: 基于 `stretch-without-user` 版本一致;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2.4'
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
ftpd:
|
||||
@ -7,12 +7,18 @@ services:
|
||||
ports:
|
||||
- "30000-30059:30000-30059"
|
||||
- "21:21"
|
||||
environment:
|
||||
- PUBLICHOST=localhost
|
||||
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
|
||||
command: /run.sh --maxclientsnumber 30 --maxclientsperip 30 --clientcharset utf8 --login puredb:/etc/pure-ftpd/pureftpd.pdb --noanonymous -j -R --passiveportrange 30000:30059
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
|
Loading…
Reference in New Issue
Block a user