windows nginx autoindex 中文目录/文件名乱码解决办法

src\http\modules\ngx_http_autoindex_module.c

// 响应处理
static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r){}

在这里插入图片描述
可以看到默认是以 html 格式响应返回的文件列表。

static ngx_buf_t *
ngx_http_autoindex_html(ngx_http_request_t *r, ngx_array_t *entries){}

typedef struct {
    ngx_str_t      name;
    size_t         utf_len;
    size_t         escape;
    size_t         escape_html;
    unsigned       dir:1;
    unsigned       file:1;
    time_t         mtime;
    off_t          size;
} ngx_http_autoindex_entry_t;

typedef struct {
    void        *elts;
    ngx_uint_t   nelts;
    size_t       size;
    ngx_uint_t   nalloc;
    ngx_pool_t  *pool;
} ngx_array_t;

ngx_http_autoindex_entry_t *entry;
entry = entries->elts;

在这里插入图片描述

关闭 uri 编码。

在这里插入图片描述

nginx.conf 的 charset 需要和系统保持一致。

观察源代码发现,在 nginx 中 url 编码和系统编码保持一致。

发布了778 篇原创文章 · 获赞 323 · 访问量 209万+

猜你喜欢

转载自blog.csdn.net/lgh1992314/article/details/88199862
今日推荐