nginx配置后端日志下载

nginx配置: 

    server {
        listen       8010;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /web/dist;
            index  index.html index.htm;
        }

        location /test {
           proxy_pass http://127.0.0.1:8016/test;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /app/file/ {
                root /data/;
                sendfile on;              # 开启高效文件传输模式
                #autoindex on;             # 开启目录文件列表
                autoindex_exact_size on;  # 显示出文件的确切大小,单位是bytes
                autoindex_localtime on;   # 显示的文件时间为文件的服务器时间
                charset utf-8,gbk;        # 避免中文乱码

                # 开启下载功能
                if ($request_filename ~* ^.*?\.(jpg|txt|doc|pdf|jpeg|gz|zip|docx|exe|xlsx|ppt|pptx)$){
                        add_header Content-Disposition attachment;
                        add_header Content-Type application/octet-stream;
                }
        }

后端日志路径:

[root@localhost sysman]# pwd 
/data/app/file/log/sysman
[root@localhost sysman]# ls
all-2024-01-02.0.log  all-2024-01-03.0.log  all-2024-01-04.0.log  all-2024-01-05.0.log  all-2024-01-06.0.log  all-2024-01-07.0.log  all-2024-01-08.0.log  all.log

日志下载地址:

http://10.10.10.10:8010/app/file/log/sysman/all.log

 

你可能感兴趣的:(nginx,运维)