nginx配置(https&文件上传之断点续传)

Nginx

目标:支持HTTPS和上传文件功能

 

一、解压缩 nginx-1.7.4离线包

tar –zxvf nginx-1.7.4.tar.gz

离线包内添加 上传文件模块包 nginx-upload-module-2.2

 

二、 编译加载https模块和上传文件模块

./configure  --prefix=/usr/local/nginx --with-http_ssl_module --add-module=nginx-upload-module-2.2/

 make & make install

三、修改nginx配置

 

https配置

server {

    listen       3072;

    server_name  ssllocalhost;

    ssl                  on;

    ssl_certificate      /etc/ssl/server.crt;

       ssl_certificate_key /etc/ssl/server.key.unsecure;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;

    ssl_ciphers  HIGH:!aNULL:!MD5;

    ssl_prefer_server_ciphers   on;

    location / {

    proxy_set_header Host $http_host;

    proxy_pass http://localhost:3070;

    }

}

 

离线上传配置

server {

       listen 3075;

        server_name 3075;

              location /resumable_upload {

              upload_resumable on;

               upload_state_store /opt/upload_temp ;//文件上传保存路径

               upload_pass @resumable_upload_handler;上传结束后通知后台接口

               upload_store /opt/upload_temp; //文件上传保存路径

                     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;

         }

     error_page 500 502 503 504 /50x.html;

       location = /50x.html{

              root html;

       }

        location @resumable_upload_handler {

                proxy_pass http://localhost:3070;

              }

}

 

四 启动关闭nginx

启动:

Nginx路径下 –c 配置文件路径

/usr/local/nginx/sbin/nginx  –c /usr/local/nginx/conf/nginx.conf

 

关闭:

Kill -9 进程  或者 kill –HUP 进程(平滑重启)

你可能感兴趣的:(信息安全,web)