docker nginx nginx - upload - module 파일 업로드

4012 단어 dockernginx
DockerFile
FROM centos:centos7
RUN yum -y update
RUN yum -y install  gcc gcc-c++ autoconf automake make
RUN yum -y install  zlib zlib-devel openssl* pcre* wget lua-devel
RUN yum -y install unzip
# nginx base
ADD nginx-1.18.0.tar.gz  /tmp
# nginx_upload_steam
ADD nginx-upload-module-2.3.0.tar.gz /tmp
ADD up.html /tmp
ADD nginx.conf /tmp

WORKDIR  /tmp  
#RUN tar zxvf 2.3.0.tar.gz 

#    Nginx
RUN useradd -M -s /sbin/nologin nginx
RUN mkdir -p /usr/local/nginx


RUN cd /tmp/nginx-1.18.0 \
    && ./configure --prefix=/etc/nginx --user=nginx --group=nginx --conf-path=/tmp/nginx.conf --with-http_ssl_module --with-http_stub_status_module --error-log-path=/tmp/error.log --http-log-path=/tmp/access.log --add-module=/tmp/nginx-upload-module-2.3.0 \
    && make  && make install

#    
 
RUN /etc/nginx/sbin/nginx -c /tmp/nginx.conf
RUN ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
 
#EXPOSE     
EXPOSE 88
 
#CMD       
#CMD ["nginx"]
CMD ["/etc/nginx/sbin/nginx","-g","daemon off;"]

nginx 프로필
worker_processes  20;
events {
    worker_connections  1024;
}
http{
    default_type  application/octet-stream;
    server{
        listen 88;
        server_name localhost;
        client_max_body_size 1024m;
        location /upload  {
            upload_store  /tmp;               #       
            upload_pass /deltaManagerDeltaUpload; #     location /deltaManagerDeltaUpload】
            upload_store_access user:rw; #      
            upload_resumable on; #    
            add_header From localhost;
            proxy_redirect  off;
            proxy_set_header   Host   $host;
            proxy_set_header   Referer $http_referer;
            proxy_set_header   Cookie $http_cookie;
            proxy_set_header   X-Real-IP  $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            upload_limit_rate 10240k;
            upload_set_form_field "${upload_field_name}_name" $upload_file_name;
            upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
            upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;
            upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
            upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;
          upload_pass_form_field "^.*$";  #    
          upload_pass_args on;    #    
          upload_cleanup 400 404 499 500-505; #                
        }
        
        location /deltaManagerDeltaUpload {
	       proxy_pass http://ip:port/video/upload; #              
	       proxy_redirect  off;
	       proxy_set_header   Host   $host;
	       proxy_set_header   Referer $http_referer;
	       proxy_set_header   Cookie $http_cookie;
	       proxy_set_header   X-Real-IP  $remote_addr;
	       proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
       }
        location / {
              root   /tmp; 
       }
    }
}

docker 실행 파일
docker stop upload
docker rm upload
docker build -t upload -f Dockerfile .
docker run -d -p 88:88 -e TZ=Asia/Shanghai --network network --name upload upload

테스트 파일



upload




다운로드 할 파일
http://nginx.org/download/nginx-1.18.0.zip
https://codeload.github.com/fdintino/nginx-upload-module/tar.gz/2.3.0
같은 디 렉 터 리 에 저장 하 는 방법
DockerFile :
FROM dimka2014/nginx-upload-with-progress-modules
MAINTAINER laowang
COPY nginx.conf /etc/nginx/nginx.conf
ADD up.html /tmp
EXPOSE 88

다른 건 일치 하면 돼.

좋은 웹페이지 즐겨찾기