備註:html
minio 是一個開源的s3 協議兼容的分佈式存儲,openresty nginx+lua 高性能可擴展的nginx 衍生版,thumbor 基於pythonpython
的圖片處理服務器,支持圖片的裁剪,識別。。。。nginx
代碼爲使用docker 構建的一個一體化的參考代碼,實際使用中,你們能夠基於本身的業務場景修改,對於簡單的場景,直接git
使用也是能夠的。github
1. 項目結構web
├── Dockerfile-nginx ├── Dockerfile-thumbor ├── README.md ├── docker-compose.yml └── nginx.conf
2. 代碼說明docker
備註:主要是對於docker-compose.yml的說明 a. docker-compose.yml version: '3' services: nginx: image: mynginx-minio build: context: . dockerfile: Dockerfile-nginx ports: - 8087:80 depends_on: - thumbor thumbor: image: mythumbor build: context: . dockerfile: Dockerfile-thumbor minio: image: minio/minio volumes: - ./data:/data - ./config:/root/.minio ports: - 9091:9000 command: server /data b. Dockerfile-nginx 很簡單,就是進行反向代理的配置 FROM openresty/openresty:alpine LABEL name="rongfengliang" LABEL version="v1.0.0" ENV name=rongfengliang ENV version=v1.0.0 COPY nginx.conf usr/local/openresty/nginx/conf/ EXPOSE 80 EXPOSE 443 EXPOSE 88 nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; resolver 127.0.0.11; # dns 配置 gzip on; real_ip_header X-Forwarded-For; real_ip_recursive on; server { listen 80; server_name localhost; real_ip_header X-Forwarded-For; real_ip_recursive on; charset utf-8; location /mydemo{ root html; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; client_body_buffer_size 10M; client_max_body_size 10G; proxy_buffers 1024 4k; proxy_read_timeout 300; proxy_pass http://minio:9000; } location /{ proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; client_body_buffer_size 10M; client_max_body_size 10G; proxy_buffers 1024 4k; proxy_read_timeout 300; proxy_pass http://thumbor/unsafe/300x200/http://minio:9000$request_uri; // 圖片處理爲300*200 的大小 } location /alert { default_type text/html; content_by_lua_block{ ngx.say([[<script>alert("error")</script>]]) } } location /ip { default_type text/html; content_by_lua_block{ ngx.say(ngx.var.remote_addr) } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 88; server_name localhost; charset utf-8; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } c. Dockerfile-thumbor thumbor 的鏡像 FROM alpine:3.6 EXPOSE 80 MAINTAINER dalong@qq.com CMD ["thumbor", "-l", "info", "-p", "80"] ENV THUMBOR_VERSION 6.3.2 RUN apk add --no-cache \ python \ libcurl \ ca-certificates \ libjpeg-turbo \ openjpeg \ libwebp \ tiff \ gcc \ py-pip \ curl-dev \ python-dev \ musl-dev \ libjpeg-turbo-dev \ openjpeg-dev \ libwebp-dev \ tiff-dev \ libressl-dev \ && export LIBRARY_PATH=/lib \ && pip install thumbor==$THUMBOR_VERSION \ && apk del gcc *-dev \ && rm -rf /var/cache/apk/* \ && rm -rf /root/.cache
3. 構建
docker-compose build
4. 運行
docker-compose up -d
5. 準備運行數據(minio 文件,以及policy 配置)
a. 獲取minio key dokcer-compose logs minio b. 輸入minio 登錄須要的key c. 建立bucket d. 設置bucket policy * read&&write
6. 參考界面
7. 參考資料
http://thumbor.org/ https://www.minio.io/ https://github.com/rongfengliang/mino-thumbor-openresty