1. 程式人生 > >Nginx的目錄檔案列表功能,和自定義header和footer

Nginx的目錄檔案列表功能,和自定義header和footer

ngx_http_autoindex_module  此模組用於自動生成目錄列表,ngx_http_autoindex_module只在 ngx_http_index_module模組未找到索引檔案時發出請求.

nginx預設是不允許列出整個目錄的。

開啟目錄列表:
開啟nginx.conf檔案,在location server 或 http段中加入
 autoindex on;

另外兩個引數最好也加上去:
autoindex_exact_size off;
預設為on,顯示出檔案的確切大小,單位是bytes。
改為off後,顯示出檔案的大概大小,單位是kB或者MB或者GB
autoindex_localtime on;


預設為off,顯示的檔案時間為GMT時間。
 改為on後,顯示的檔案時間為檔案的伺服器時間

配置Nginx目錄列表的方法詳細參照:http://wiki.nginx.org/NginxChsHttpAutoindexModule

Requirements

  • Sources for Nginx_ 0.8.x, and its requirements.
    • The module compiles with 0.7.x versions as well.
    • It _might_ compile with 0.6.x applying "nginx-0.6-support.patch", YMMV.
  • Patience, and some Coffee™.

Building

1. Unpack the Nginx_ sources::

   $ gunzip -c nginx-?.?.?.tar.gz | tar -xvf -

2. Download the latest version using Git:

3. Change to the directory which contains the Nginx_ sources, run the

  configuration script with the desired options and be sure to put an
  ``--add-module`` flag pointing to the directory which contains the source
  of the fancy indexing module::
   $ cd nginx-?.?.?
   $ ./configure --add-module=../ngx-fancyindex  [extra desired options]

4. Build and install the software::

   $ make
  And then, as ``root``::
   # make install

5. Configure Nginx_ by using the modules' configuration directives_.

Example Enable

You can test the default built-in style by adding the following lines into a ``server`` section in your Nginx_ configuration file::

 location / {
   fancyindex on;              # Enable fancy indexes.
   fancyindex_exact_size off;  # Output human-readable file sizes.
 }

Directives

fancyindex

Syntax: *fancyindex* [*on* | *off*]
Default: fancyindex off
Context: http, server, location
Description:
 Enables or disables fancy directory indexes.

fancyindex_css_href

Syntax: *fancyindex_css_href uri*
Default: fancyindex_css_href ""
Context: http, server, location
Description:
 Allows inserting a link to a CSS style sheet in generated listings. The
 provided *uri* parameter will be inserted as-is in a ``<link>`` HTML tag.
 The link is inserted after the built-in CSS rules, so you can override the
 default styles.

fancyindex_exact_size

Syntax: *fancyindex_exact_size* [*on* | *off*]
Default: fancyindex_exact_size on
Context: http, server, location
Description:
 Defines how to represent file sizes in the directory listing; either
 accurately, or rounding off to the kilobyte, the megabyte and the
 gigabyte.

fancyindex_footer

Syntax: *fancyindex_footer path*
Default: fancyindex_footer ""
Context: http, server, location
Description:
 Specifies which file should be inserted at the foot of directory listings.
 If set to an empty string, the default footer supplied by the module will
 be sent.

.. warning:: When inserting custom header/footer a subrequest will be

  issued so potentially any URL can be used as source for them. Although it
  will work with external URLs, only using internal ones is supported.
  External URLs are totally untested and using them will make Nginx_ block
  while waiting for the subrequest to complete. If you feel like external
  header/footer is a must-have for you, please
  `let me know <mailto:[email protected]>`__.

fancyindex_header

Syntax: *fancyindex_header path*
Default: fancyindex_header ""
Context: http, server, location
Description:
 Specifies which file should be inserted at the head of directory listings.
 If set to an empty string, the default header supplied by the module will
 be sent.

fancyindex_ignore

Syntax: *fancyindex_ignore string1 [string2 [... stringN]]*
Default: No default.
Context: http, server, location
Description:
 Specifies a list of file names which will be not be shown in generated
 listings. If Nginx was built with PCRE support strings are interpreted as
 regular expressions.

fancyindex_localtime

Syntax: *fancyindex_localtime* [*on* | *off*]
Default: fancyindex_localtime off
Context: http, server, location
Description:
 Enables showing file times as local time. Default is “off” (GMT time).

相關推薦

Nginx目錄檔案列表功能,定義headerfooter

ngx_http_autoindex_module  此模組用於自動生成目錄列表,ngx_http_autoindex_module只在 ngx_http_index_module模組未找到索引檔案時發出請求. nginx預設是不允許列出整個目錄的。 開啟目錄列表:

SpringMvc支援跨域定義header

<!-- 支援options型別請求 --> <servlet> <servlet-name>application</servlet-name> <servlet-class&g

Android零基礎入門第39節:ListActivity定義列表

arraylist component save 高速 ram 如果 view設置 ren 屬性 相信通過前兩期的學習,以及會開發最簡單的一些列表界面了吧,那麽本期接著來學習更多方法技巧。 一、使用ListActivity 如果程序的窗口僅僅需要

定義使用者認證 中介軟體 檔案上傳/oss 圖片驗證碼

自定義使用者 寫一個繼承自AbstractUser的類,然後追加自己需要的欄位 在settings.py加入AUTH_USER_MODEL = 'app的名字.使用者類' 自定義使用者認證 步驟 在app的目錄下新鍵一個檔案 auth.py 寫一個繼承自ModeBacke

Android開發(AlertDialog對話方塊定義佈局多選列表不共存的替代辦法)

這個實現功能花了一點時間,當時忙了很晚,只怪當時沒有想出其他解決辦法。言歸正傳。 前幾天有這麼一個小夥伴,在開發有這樣的地圖app,該地圖app有多個地圖圖層,這些地圖圖層可提供給使用者操作,比如說圖層的顯示控制,以及選擇需要的圖層供查詢。由於該地圖app在主介面已經佈局很

vue定義元件列表迴圈--vue學習筆記

<div id="app"> <shaoyou v-for='item in listData' v-bind:myProps='item' v-bind:ke

Android使用開源框架完成城市列表三級聯動(從服務端獲取資料來源定義json資料來源)

Android-PickerView使用步驟:1.新增Jcenter倉庫 Gradle依賴:compile 'com.contrarywind:Android-PickerView:4.1.4'2.在Activity中新增如下程式碼:package com.xueqing.r

Docker技術入門與實戰 第二版-學習筆記-8-網路功能network-3-容器訪問控制定義網橋

1)容器訪問控制 容器的訪問控制,主要通過 Linux 上的 iptables防火牆來進行管理和實現。 iptables是 Linux 上預設的防火牆軟體,在大部分發行版中都自帶。   容器訪問外部網路 容器要想訪問

Spring-boot中讀取核心配置檔案application定義properties配置檔案的方式

前言:瞭解過spring-Boot這個技術的,應該知道Spring-Boot的核心配置檔案application.properties,當然也可以通過註解自定義配置檔案**.properties的資

如何在dede首頁欄目列表頁呼叫定義欄位

1.首頁呼叫。 {dede:arclist addfields='欄位英文名' channelid='模型ID' row='條數' type='欄目ID'}[field:欄位英文名/]{dede:arclist} 2.新模型頁面呼叫 {dede:field name='英文欄位名'/} 3. 列表頁

Log4J日誌配置詳解定義log4j日誌級別及輸出日誌到不同檔案實現方法

package com.jo.work.log4j; import java.util.Enumeration; import org.apache.log4j.Appender; import org.apache.log4j.FileAppender; import org.apache.log4j.

Xcode定義.h.m中檔案的個性化註釋(公司、版本、作者、版權宣告等)

每個iOS開發者新建class檔案的時候都可以看到檔案最上面宣告的一些基本資訊。而這些資訊都是預設的,我們現在就要來自定義這些資訊。新增一些自己想要新增的,比如Github連結等等。 1.下面為預設的資訊 // // VideoCell.m // W

Android中Spinner下拉列表(使用ArrayAdapter定義Adapter實現)

     今天學習了Spinner元件,使用Spinner相當於從下拉列表中選擇專案,下面演示一下Spinner的使用(分別使用ArrayAdapter和自定義Adapter實現) (一):使用Arr

nginx檢視預設安裝模組定義安裝模組

檢視預設安裝模組 [[email protected] ~]# tar -xaf nginx-1.10.3.tar.gz [[email protected] ~]#cd nginx-1.10.3/ [[email protected] n

C#訪問共享目錄 得到共享目錄檔案列表修改裡面的檔案

建一個IdentityScope類,並引用相應的包using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Intero

【Android】 XML佈局檔案中,使用定義屬性不提示不生效

在XML檔案中使用首先要宣告 xmlns:toolbar=http://schemas.android.com/apk/res/cn.zzm.toolbar 注意,“toolbar”可以換成其他的任何名字,後面的url地址必須最後一部分必須用上自定義元件的包名。自定義屬性了

SpringBoot 定義filter interceptor,定義靜態檔案存放位置

上篇分享我們已經有了一個最基礎具有登陸驗證功能 的SpringBoot web專案,本篇對照之前SpringMVC 的xml配置,闡述SpringBoot 中的filter 和 interceptor。 一、web.xml中的filter 和 SpringBo

使用tomcat配置檔案下載伺服器,定義下載列表

http://www.cnblogs.com/huxdiy/p/tomcat%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD.html 先上圖,利用tomcat,這個下載介面沒有程式碼,點選檔名即可下載 詳細參考:http://tomcat.ap

Django定義圖片檔案上傳路徑(upload_to)的2種方式

最近在做一個仿知乎網站的專案了,裡面涉及很多圖片和檔案上傳。趁此機會我給大家總結下Django自定義圖片和檔案上傳路徑的2種方式吧。方法1: 在Django模型中定義upload_to選項。Django

python呼叫jieba(結巴)分詞 加入定義詞典去停用詞功能

#!/usr/bin/python #-*- encoding:utf-8 -*- import jieba #匯入jieba模組 import re jieba.load_userdict("newdict.t