OpenLiteSpeed Web Server Users' Manual

Version 1.4 Rev. 2

CGI Context

Table of Contents

CGI Context

URI | Path | Extra Headers | Allow Set UID | Realm | 认证名称 | Require(授权的用户/组) | 允许访问列表 | 拒绝访问列表 | Authorizer | 添加默认的字符集 | 自定义默认字符集 | Enable Rewrite | 重写继承 | 重写基准 | Rewrite Rules | 启用IP地理定位 | 

CGI ContextGo to top

Description

A CGI context defines scripts in a particular directory as CGI scripts. This directory can be inside or outside of the document root. When a file under this directory is requested, the server will always try to execute it as a CGI script, no matter if it's executable or not. In this way, file content under a CGI Context is always protected and cannot be read as static content. It is recommended that you put all your CGI scripts in a directory and set up a CGI Context to access them.

URIGo to top

Description

Specifies the URI for this context.

Syntax

The URI can be a plain URI (starting with "/") or a Perl compatible regular expression URI (starting with "exp:"). If a plain URI ends with a "/", then this context will include all sub-URIs under this URI. If the context maps to a directory on the file system, a trailing "/" must be added.

See Also

Location

PathGo to top

Description

Specifies the location of CGI scripts.

Syntax

The path can be a directory that contains a group of CGI scripts, like $VH_ROOT/myapp/cgi-bin/. In this case, the context URI must end with "/", like /app1/cgi/. The Path can also specify only one CGI script, like $VH_ROOT/myapp/myscript.pl. This script should have the corresponding URI /myapp/myscript.pl.

Extra HeadersGo to top

Description

Specifies extra response headers to be added. Multiple headers can be added, one header per line. Put "NONE" to disable headers inherited from parent content.

Syntax

"[HeaderName]: [HeaderValue]" in each line.

Example

Cache-control: no-cache, no-store
My-header: Custom header value

Allow Set UIDGo to top

Description

Specifies whether the set UID bit is allowed for CGI scripts. If the set UID bit is allowed and the set UID bit is enabled for a CGI script, no matter which user the CGI script was started on behalf of, the user ID of the CGI process will switch to the user ID of the owner of the CGI script.
The default is "Off".

Syntax

Select from radio box

Tips

[Security] Do not allow Set UID CGI scripts whenever possible, as it is inherently a security risk.

RealmGo to top

Description

指定这个context下的realm授权。 当指定时,必须提供有效的用户和用户名来访问这个context。 Realms授权需要在Virtual Host Security部分进行设置。此设置使用每个realm的Realm名称

Syntax

选项

认证名称Go to top

Description

为当前context下的realm认证指定一个替代的名称。 如果没有指定,原realm名称将被使用。 认证名称将显示在浏览器登陆弹出窗口。

Syntax

文本

Require(授权的用户/组)Go to top

Description

指定哪些用户/用户组可以访问此context。 这里允许你使用一个用户/组数据库(在 Realm中指定)访问多个context, 但只允许该数据库下特定的用户/组访问这个context。

Syntax

语法兼容Apache的Require指令。例如:

  • user username [username ...]
    只有列出的用户可以访问这个context;
  • group groupid [groupid ...]
    用户必须属于列出的组才可以访问这个context。
如果没有指定,所有有效的用户都可以访问这个资源。

允许访问列表Go to top

Description

指定允许访问这个context下资源的IP地址或子网。综合 拒绝访问列表项的配置以及服务器/虚拟主机级别访问控制, 可访问性将以客户端IP所符合的最小范围来确定。

Syntax

逗号分隔的IP地址/子网列表。

Example

子网络可以写成192.168.1.0/255.255.255.0, 192.168.1192.168.1.*

拒绝访问列表Go to top

Description

指定哪个IP地址或子网不被允许访问这个context下的资源。 综合允许访问列表项的配置以及服务器/虚拟主机级别访问控制, 可访问性将以客户端IP所符合的最小范围来确定。

Syntax

逗号分隔的IP地址/子网列表。

Example

子网络可以写成192.168.1.0/255.255.255.0, 192.168.1192.168.1.*

AuthorizerGo to top

Description

Specifies an external application that can be used to generate authorized/unauthorized decisions. Currently, only the FastCGI Authorizer is available. For more details about the FastCGI Authorizer role, please visit http://www.fastcgi.com.

Syntax

Select from drop down list

添加默认的字符集Go to top

Description

指定当内容类型是"text/html"或"text/plain"且没有参数时,是否添加字符集标记到"Content-Type"响应报头中。当设置为Off时,该功能禁用。当设置为On时,将添加自定义默认字符集中指定的字符集,如果没有指定,将添加默认的"iso-8859-1"字符集。

Syntax

布尔值

自定义默认字符集Go to top

Description

指定一个字符集当添加默认的字符集On时使用。这是可选的。默认值是iso-8859-1。当添加默认的字符集Off时本设置将不生效。

Syntax

字符集的名称,例如utf-8

Example

utf-8

Enable RewriteGo to top

Description

Specifies whether to enable LiteSpeed's URL rewrite engine. This option can be customized at the virtual host or context level, and is inherited along the directory tree until it is explicitly overridden.

Syntax

Select from radio box

重写继承Go to top

Description

指定是否从父级context继承重写规则。 如果启用重写但不继承,将启用本context的重写基准及重写规则。

Syntax

布尔值

重写基准Go to top

Description

指定重写规则的基准URL。

Syntax

URL

Rewrite RulesGo to top

Description

Specifies a list of rewrite rules at the virtual host or context level. A rewrite rule is comprised of one RewriteRule directive and optionally preceded by multiple RewriteCond directives.

  • Each directive should take only one line.
  • RewriteCond and RewriteRule follow Apache's rewrite directive syntax. Just copy and paste rewrite directives from your Apache configuration files.
  • There are minor differences between LiteSpeed and Apache mod_rewrite implementation:
    • %\{LA-U:variable\} and %\{LA-F:variable\} are ignored by the LiteSpeed rewrite engine
    • two new server variables are added in the LiteSpeed rewrite engine: %\{CURRENT_URI\} represents the current URI being processed by the rewrite engine and %\{SCRIPT_NAME\} has the same meaning as the corresponding CGI environment variable.
The implementation of LiteSpeed's rewrite engine follows the Apache's rewrite engine specifications. For more details about rewrite rules, please refer to Apache's mod_rewrite document and Apache's URL rewriting guide.

Syntax

string

启用IP地理定位Go to top

Description

指定是否启用IP地理定位查找。 可以在服务器级别,虚拟主机级别,或context级别设置。

Syntax

布尔值

See Also

使用报头中的客户端IP, 数据库文件路径, 数据库缓存类型