nginx可以通过修改源代码,实现自定义版本和个性化的目录列表
源码可以到http://nginx.org/下载
下载http://nginx.org/download/nginx-1.0.8.tar.gz
解压,文本编辑器打开
/nginx-1.0.8/src/core/nginx.h
内容如下:
/* * Copyright (C) Igor Sysoev */ #ifndef _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_ #define nginx_version 1000008 #define NGINX_VERSION "1.0.8" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" #endif /* _NGINX_H_INCLUDED_ */
将
#define NGINX_VERSION "1.0.8" #define NGINX_VER "nginx/" NGINX_VERSION
改为
#define NGINX_VERSION "1.9.88" /*版本号,自己改*/ #define NGINX_VER "Your string here" /*显示版本时直接显示此字符串*/
保存,重新编译即可。
文本编辑器打开
/nginx-1.0.8/src/http/modules/ngx_http_autoindex_module.c
修改第120行,可以自己添加style修改样式。
修改361-402行,可以自定义列表html。
以下是我自己修改的一个
ngx_http_autoindex_module
此模块用于自动生成目录列表. 只在 ngx_http_index_module模块未找到索引文件时发出请求.
__配置实例__
location / { autoindex on; } #autoindex #syntax: autoindex [ on|off ] #default: autoindex off #context: http, server, location #激活/关闭自动索引 #autoindex_exact_size #syntax: autoindex_exact_size [ on|off ] #default: autoindex_exact_size on #context: http, server, location #设定索引时文件大小的单位(B,KB, MB 或 GB) Template:Anchor #autoindex_localtime #syntax: autoindex_localtime [ on|off ] #default: autoindex_localtime off #context: http, server, location #开启以本地时间来显示文件时间的功能。默认为关(GMT时间)