码迷,mamicode.com
首页 > 其他好文 > 详细

Docker Nginx pure-ftp 搭建图片服务器

时间:2018-07-25 12:44:11      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:var   ESS   connect   form   com   opus   修改   docke   col   

1.docker 配置 pure-ftp

(1)安装docker和docker-compose

sudo apt-get install docker.io
sudo apt-get install docker-compose

 

(2) 创建文件路径

mkdir /home/ftpfile

 

(3) 进入任意工作目录

mkdir pure-ftp
cd pure-ftp

 

(4)配置pure-ftpd(具体配置可根据需要更改, 可参考 https://blog.csdn.net/shanzhongyinzhe/article/details/49639703 )

vim pure-ftpd.conf

 

(5)编辑docker-compose文件

 vim docker-compose.xml 

ftp:
  image: "stilliard/pure-ftpd"
  ports:
    - "21:21"
    - "30000:30000"
    - "30001:30001"
    - "30002:30002"
    - "30003:30003"
    - "30004:30004"
    - "30005:30005"
    - "30006:30006"
    - "30007:30007"
    - "30008:30008"
    - "30009:30009"
  volumes:
    - "/home/ftpfile:/home/ftpfile"
    - "./pure-ftpd:/etc/pure-ftpd"
  environment:
    PUBLICHOST: "localhost"


(6)  docker-compose up -d 


(7) 进入ftp容器内

docker exec -it pureftp_ftp_1 /bin/bash

 

(8) 创建ftp虚拟用户

pure-pw useradd user1 -u deity -g ftpgroup -d /home/ftpfile
pure-pw mkdb

 

(9) 重启pure-ftp

service pure-ftpd restart

 

 


2.docker 配置 nginx

(1) 进入任意工作目录

mkdir nginx
cd nginx

(2)  vim nginx.conf 

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main $remote_addr - $remote_user [$time_local] "$request" 
$status $body_bytes_sent "$http_referer" 
"$http_user_agent" "$http_x_forwarded_for";

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

  nginx.conf可以去nginx官网下载,然后在末尾花括号前加上 include /etc/nginx/conf.d/*.conf;  即可。

 

(3) 编写子配置文件

mkdir nginx.conf.d
cd nginx.conf.d

 

(4) vim image.vvshow.com.conf 

 

server {
    listen 80;
    autoindex off;
    server_name image.vvshow.com;
    access_log /var/log/nginx/access.log combined;
    index index.html index.htm index.jsp;
    
    if ( $query_string ~* ".*[\;‘\<\>].*" ) {
        return 404;
    } 
    

    location / {
        root /home/ftpfile;
        add_header Access-Control-Allow-Origin *;

    }
}

 

 

(5)  cd ..  vim docker-compose.xml 

 

nginx:
image: "hub.c.163.com/library/nginx"

ports: 
- "80:80"

volumes:
- "/home/ftpfile:/home/ftpfile"
- "./nginx.conf:/etc/nginx/nginx.conf"
- "./nginx.conf.d:/etc/nginx/conf.d"

environment:
PUBLICHOST: "localhost"

 

(6)  docker-compose up -d 

 

(7) 修改/etc/hosts,可将本机ip 映射域名为 image.vvshow.com

 

(8) 此时浏览器访问image.vvshow.com 映射的为 /home/ftpfile目录

 

注:pure-ftp 和 nginx 的docker-compose.xml 内容可以合在一起

 

Docker Nginx pure-ftp 搭建图片服务器

标签:var   ESS   connect   form   com   opus   修改   docke   col   

原文地址:https://www.cnblogs.com/Duolaimon/p/9365233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!