Nginx - Additional Modules, Website Access and Logging
The following set of modules allows you to configure how visitors access your website and the way your server logs requests.
Index
The Index module provides a simple directive named index, which lets you define the page that Nginx will serve by default if no filename is specified in the client request (in other words, it defines the website index page). You may specify multiple filenames; the first file to be found will be served. If none of the specified files are found, Nginx will either attempt to generate an automatic index of the files, if the autoindex directive is enabled, or return a 403 Forbidden error page.
Optionally, you may insert an absolute filename (such as /page.html) but only as the last argument of the directive.
Syntax: index file1 [file2…] [absolute_file];
Default value: index.html
Eaxmple:
index index.php index.html index.htm;
index index.php index2.php /catchall.php;
This directive is valid in the following contexts: http, server, location.
Autoindex
If Nginx cannot provide an index page for the requested directory, the default behavior is to return a 403 Forbidden HTTP error page. With the following set of directives, you enable an automatic listing of the files that are present in the requested directory:

Three columns of information appear for each file—the filename, the file date and time, and the file size in bytes.
autoindex
Context: http, server, location
Enables or disables automatic directory listing for directories missing an index page.
Syntax: on or off
autoindex_exact_size
Context: http, server, location
If set to on, this directive ensures that the listing displays file sizes in bytes. Otherwise, another unit is employed, such as KB, MB, or GB.
Syntax: on or off
Default value: on
autoindex_localtime
Context: http, server, location
By default, this directive is set to off, so the date and time of files in the listing appears as GMT time. Set it to on to make use of the local server time.
Syntax: on or off
Default value: off
Random Index
This module enables a simple directive, random_index, which can be used within a location block in order for Nginx to return an index page selected randomly among the files of the specified directory.
This module is not included in the default Nginx build.
Syntax: on or off
Log
This module controls the behavior of Nginx regarding access logs. It is a key module for system administrators as it allows analyzing the runtime behavior of web applications. It is composed of three essential directives:
access_log
Context: http, server, location
This parameter defines the access log file path, the format of entries in the access log by selecting a template name, or disables access logging.
Syntax: access_log path [format [buffer=size]] | off;
Some remarks concerning the directive syntax:
- Use access_log off to disable access logging at the current level
- The format argument corresponds to a template declared with the log_format directive, described below
- If the format argument is not specified, the default format is employed (combined)
- You may use variables in the file path
log_format
Context: http, server, location
Defines a template to be utilized by the access_log directive, describing the contents that should be included in an entry of
the access log.
Syntax: log_format template_name format_string;
The default template is called combined and matches the following example:
log_format combined '$remote_addr - $remote_user [$time_local] '"$request" $status $body_bytes_sent '"$http_referer" "$http_user_agent"';
# Other example
log_format simple '$remote_addr $request';
open_log_file_cache
Context: http, server, location
Configures the cache for log file descriptors. Please refer to the open_file_cache directive of the HTTP Core Module for additional information.
Syntax: open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time] | off;
The arguments are similar to the open_file_cache and other related directives; the difference being that this applies to access log files only.
The Log module also enables several new variables, though they are only accessible when writing log entries:
- $connection: The connection number
- $pipe: The variable is set to "p" if the request was pipelined
- $time_local: Local time (at the time of writing the log entry)
- $msec: Local time (at the time of writing the log entry) to the microsecond
- $request_time: Total length of the request processing, in milliseconds
- $status: Response status code
- $bytes_sent: Total number of bytes sent to the client
- $body_bytes_sent: Number of bytes sent to the client for the response body
- $apache_bytes_sent: Similar to $body_bytes, which corresponds to the %B parameter of Apache's mod_log_config
- $request_length: Length of the request body
Nginx - Additional Modules, Website Access and Logging的更多相关文章
- Nginx - Additional Modules, About Your Visitors
The following set of modules provides extra functionality that will help you find out more informati ...
- Nginx - Additional Modules, Limits and Restrictions
The following modules allow you to regulate access to the documents of your websites — require users ...
- Nginx - Additional Modules, Content and Encoding
The following set of modules provides functionalities having an effect on the contents served to the ...
- Nginx - Additional Modules, SSL and Security
Nginx provides secure HTTP functionalities through the SSL module but also offers an extra module ca ...
- 通过Nginx,Tomcat访问日志(access log)记录请求耗时
一.Nginx通过$upstream_response_time $request_time统计请求和后台服务响应时间 nginx.conf使用配置方式: log_format main '$remo ...
- Thinkphp框架网站 nginx环境 访问页面access denied
今日不熟一个tiinkphp框架网站的时候,由于服务器环境是centos6.5+nginx1.8,已经运行php商城项目很正常, 本以为一切比较简单,直接新建了项目文件夹,xftp上传了程序,并配置n ...
- linux+nginx+phpfpm 访问出现Access denied错误解决方案
linux上安装nginx,php-fpm后访问页面一直出现Access denied错误. 网上搜原因大概如下图: 我试了第一个方案,然后就好了.
- Table of Contents - Nginx
Downloading and Installing Nginx Nginx for Windows Basic Nginx Configuration Configuration File Syn ...
- nginx---reference
nginx (pronounced "engine x") is a free open source web server written by Igor Sysoev, a R ...
随机推荐
- 2015年必火的五个Html5移动开发工具推荐
NO.1 DCloudHBuilder:基于HTML5开发工具 中文官网:http://www.dcloud.io/ DCloudHBuilder:基于HTML5开发工具是当前最快的HTML开发工 ...
- Java中重写与重载的辨析
摘要:在我们学习Java过程中,重写与重载使我们在面向对象里要学习的重要知识点之一,那我们看看它们有那些区别: 一.重写 1.概念:简单的说就是子类将从父类继承而来的方法重新实现一次. 2.特点: ① ...
- 图片攻击-BMP图片中注入恶意JS代码 <转载>
昨天看到一篇文章<hacking throung images>,里面介绍了如何在BMP格式的图片里注入JS代码,使得BMP图片既可以正常显示, 也可以运行其中的JS代码,觉得相当有趣. ...
- Struts2内建校验器(基于校验框架的文件校验)
位于xwork-2.0.4.jar压缩包中( com.opensymphony.xwork2.validator.validators)有个文件default.xml ,该文件中定义了Struts2框 ...
- C++11新特性(3) lambda表达式(1)
C++11加入了一项名为lambda表达式的新功能.通过这项功能能编写内嵌的匿名函数,而不必编写独立函数或函数对象,使得代码更加理解. lambda表达式包括下面部分. [capture_block] ...
- cocos2dx 3.0 触摸机制
在cocos2dx 3.0版本号中,废弃了以往2.x版本号的写法,我们先来看一下Layer.h中的一段代码 /* Callback function should not be deprecated, ...
- 一个无聊的实验:验证网站是否通过web容器还是微服务部署
一般来说一台web服务器会部署多个实例(且共享80端口),举个栗子例如nginx通常部署多个站点,每个站点都有自己的端口 例如 8091,8092之类的. 通过nginx进行代理.(前提微服务直接使用 ...
- java 覆盖hashCode()深入探讨 代码演示样例
java 翻盖hashCode()深入探讨 代码演示样例 package org.rui.collection2.hashcode; /** * 覆盖hashcode * 设计HashCode时最重要 ...
- X64 Win7(win2008)连接SqlServer2005慢的解决办法
问题描述:数据库版本:SQL SERVER 2005数据库安装环境: Win 2003 X64 客户端环境:Win 2008 x64连接工具:ODBC或ado.net测试连接时间:4-6秒 客户端环境 ...
- android Camera 数据流程分析
这篇文章主要针对其数据流程进行分析.Camera一般用于图像浏览.拍照和视频录制.这里先对图像浏览和拍照的数据流进行分析,后面再对视频电话部分进行分析. 1.针对HAL层对摄像头数据处理补充一下 Li ...