zoukankan      html  css  js  c++  java
  • nginx 配置文件下载服务

    1.创建存放下载文件目录,传入文件

    # 注释:nginx服务为yum安装
    
    [root@nginx ~]# mkdir /etc/nginx/downloadFile
    
    [root@nginx ~]# ll /etc/nginx/downloadFile/
    total 32
    -rw-r--r-- 1 root root 13392 Sep 24 16:09 1.gif
    -rw-r--r-- 1 root root 12947 Sep 24 16:13 picture.tar.gz

    2.配置nginx

    [root@centos7 downloadFile]# cat /etc/nginx/nginx.conf
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    include /usr/share/nginx/modules/*.conf;
    events {
        worker_connections 1024;
    }
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=512m;
        access_log  /var/log/nginx/access.log  main;
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
        #include /etc/nginx/conf.d/*.conf;
        server {
            listen       80;
            root   /usr/share/nginx/html ;
            proxy_cache_key  $host$uri;
            proxy_set_header  Host  $host;
            proxy_set_header    X-real-ip $remote_addr;
            proxy_set_header  X-Forwarded-For  $remote_addr;
            location / {
                  root /etc/nginx/downloadFile;   # 指定实际目录绝对路径
                  autoindex on;                   # 开启目录浏览功能
                  autoindex_exact_size off;       # 关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b
                  autoindex_localtime on;         # 开启以服务器本地时区显示文件修改日期
           }
        }
    }

    3.展示效果

    #######

  • 相关阅读:
    Jquery
    JavaScript
    poj--2115 C Looooops
    poj--3970 party
    poj 1061 青蛙的约会
    hdu1250--Hat's Fibonacci
    2318--TOYS
    扩展欧几里得--让你一次刷个够
    关于大数加法的解法
    有关环形数组的约瑟夫问题
  • 原文地址:https://www.cnblogs.com/faithH/p/13724668.html
Copyright © 2011-2022 走看看