ngx_http_core_module模块基本指令整理4

  categories:资料  author:

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_core_module模块做简单介绍,本文具体包括如下指令:

http,if_modified_since,ignore_invalid_headers,internal,keepalive_disable,keepalive_requests

20. http

syntax:

http { … }

default:

context:

main

为http服务器相关配置指令提供一个上下文环境

原文如下:

Provides a configuration file context in which the HTTP server directives are specified.

21. if_modified_since

syntax:

if_modified_since   off | exact | before;

default:

if_modified_since exact;

context:

http, server, location

规定如何对相应时间同请求头中“If-Modified-Since”字段的值进行比较。

Off

“If-Modified-Since” 字段的请求被忽略

Exact

精确匹配

Before

修改时间小于或者等于这个请求头中“If-Modified-Since”字段的值。

Nginx官方解释如下:

Specifies how to compare modification time of a response with the time in the “If-Modified-Since” request header field:

off

    the “If-Modified-Since” request header field is ignored (0.7.34);

exact

    exact match;

before

modification time of a response is less than or equal to the time in the “If-Modified-Since” request header field.

22. ignore_invalid_headers

syntax:

ignore_invalid_headers   on | off;

default:

ignore_invalid_headers on;

context:

http, server

控制是否头部的非法名称的header应该被忽略。合适的名称是由因为字母,数字,连字符,可能的下划线(由underscores_in_headers指令控制)。

指令可以在默认的server级别制定。在这个情况下,他的量将覆盖箭筒在相同ip及端口的全部虚拟主机。

Nginx官方解释如下:

Controls whether header fields with invalid names should be ignored. Valid names are composed of English letters, digits, hyphens, and possibly underscores (as controlled by the underscores_in_headers directive).

A directive can be specified on the server level in a default server. In this case, its value will cover all virtual servers listening on the same address and port.

23. internal

syntax:

internal;

default:

context:

location

制定一个location仅仅能被内部请求访问。对于外部请求, 这个请求的客户端将收到404(未发现的)错误信息。内部请求可以是如下:

从定向请求,包括:error_page,index, random_index, 及try_files指令。

请求可以是带有“X-Accel-Redirect”响应头的从定向指令(从反向代理服务器返回的)从定向指令。

从include 虚拟机命令的ngx_http_ssi_module 模块及ngx_http_addition_module 模块的资料。

被重写指令改变的请求。

例如如下:

error_page 404 /404.html;

    location /404.html {

        internal;

    }

internal 从定向指令最多10次循环,在一个请求中, 当超过这个数量限制时, 用户将被返回500错误信息。在这个情况下, 重写或者内部循环指令的车位消息能被出现在日志中。

Nginx官方解释如下:

Specifies that a given location can only be used for internal requests. For external requests, the client error 404 (Not Found) is returned. Internal requests are the following:

    requests redirected by the error_page, index, random_index, and try_files directives;

    requests redirected by the “X-Accel-Redirect” response header field from an upstream server;

    subrequests formed by the “include virtual” command of the ngx_http_ssi_module module and by the ngx_http_addition_module module directives;

    requests changed by the rewrite directive.

Example:

    error_page 404 /404.html;

    location /404.html {

        internal;

    }

    There is a limit of 10 internal redirects per request to prevent request processing cycles that can occur in incorrect configurations. If this limit is reached, the error 500 (Internal Server Error) is returned. In such cases, the “rewrite or internal redirection cycle” message can be seen in the error log.

24. keepalive_disable

syntax:

keepalive_disable  none | browser …;

default:

keepalive_disable msie6;

context:

http, server, location

禁止同行为不端的浏览器保持长连接。浏览器参数指定的浏览器将收到影响。Msie6参数将禁止同老版本的ie浏览器建立长连接。Safari参数将禁止Safari或者类似Safari的在Mac OS X平台或者类似的浏览器建立长连接。None参数禁止全部浏览器的长连接请求。

1.1.18版本前,safari参量匹配全部平台的全部safari或者safari类似的浏览器, 然后这些浏览器的长连接都将被禁止。

Nginx官方解释如下:

Disables keep-alive connections with misbehaving browsers. The browser parameters specify which browsers will be affected. The value msie6 disables keep-alive connections with old versions of MSIE, after seeing a POST request. The value safari disables keep-alive connections with Safari and Safari-like browsers on Mac OS X and Mac OS X-like operating systems. The value none enables keep-alive connections with all browsers.

    Prior to version 1.1.18, the value safari matched all Safari and Safari-like browsers on all operating systems, and keep-alive connections with them were disabled by default.

25. keepalive_requests

syntax:

keepalive_requests   number;

default:

keepalive_requests 100;

context:

http, server, location

This directive appeared in version 0.8.0.

设置一个长连接中最多可以允许的request请求数量。当超过这个数量后,这个连接被释放。

Nginx官方解释如下:

Sets the maximum number of requests that can be made through one keep-alive connection. After this many requests are made, the connection is closed.



快乐成长 每天进步一点点