## OpenLiteSpeed Web Server Users' Manual

### Version 1.7 — Rev. 26

- License
- Introduction
- Installation
- Administration
  - Service Manager
- Security
- Configuration
  - Server General
  - Server Log
  - Server Tuning
  - Server Security
  - External Apps
  - Fast CGI App
  - Fast CGI Authorizer
  - LSAPI App
  - Servlet Engine
  - Web Server
  - Piped logger
  - Load Balancer
  - Script Handler
  - App Server Settings
  - Module Configuration
  - Listener General
  - Listener SSL
  - Virtual Host Templates
  - Virtual Host Basic
  - Virtual Host General
  - Virtual Host Security
  - Virtual Host SSL
  - Rewrite
  - Context
  - Static Context
  - Java Web App Context
  - Servlet Context
  - Fast CGI Context
  - LSAPI Context
  - Proxy Context
  - CGI Context
  - Load Balancer Context
  - Redirect Context
  - App Server Context
  - Module Handler Context
  - Web Socket Proxy
- Web Console
  - Admin Console General
  - Admin Console Security
  - Admin Listener General
  - Admin Listener SSL

# Static Context

## Table of Contents

### Static Context⇑

#### Description

Context settings are used to specify special settings for files in a certain location. These settings can be used to bring in files outside of the document root (like Apache's Alias or AliasMatch directives), to protect a particular directory using authorization realms, or to block or restrict access to a particular directory within the document root.

### URI⇑

#### 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

### Location⇑

#### Description

Specifies the corresponding location of this context in the file system.
Default value: $DOC_ROOT + URI

#### Syntax

It can be an absolute path or path relative to $SERVER_ROOT, $VH_ROOT, or $DOC_ROOT. $DOC_ROOT is the default relative path, and can be omitted.
If the URI is a regular expression, then the matched sub-string can be used to form the "Root" string. The matched sub-string can be referenced with the values "$1" - "$9". "$0" and "&" can be used to reference the whole matched string. Additionally, a query string can be set by appending a "?" followed by the query string. Be careful. "&" should be escaped as "\&" in the query string.

#### Example

A plain URI like /examples/ with Location set to /home/john/web_examples will map the request "/examples/foo/bar.html" to file "/home/john/web_examples/foo/bar.html".
To simulate Apache's mod_userdir, set URI to exp: ^/~([A-Za-z0-9]+)(.*), set Location to /home/$1/public_html$2. With these settings, a request of URI /~john/foo/bar.html will map to file /home/john/public_html/foo/bar.html.

#### See Also

URI

### Accessible⇑

#### Description

Specifies whether this context can be accessed. Set to No to deny access. You can use this feature to protect the specified directory from being visited. You may use it when you are updating contents for this context or you have special data in this directory.

#### Syntax

Select from radio box

### Enable Expires⇑

#### Description

Specifies whether to generate an Expires header for static files. If enabled, an Expires header will be generated based on Expires Default and Expires By Type.
This can be set at server, virtual host and context level. Lower level settings will override higher level ones, i.e. context settings will override virtual host settings and virtual host settings will override server settings.

#### Syntax

Select from radio box

### Expires Default⇑

#### Description

Specifies default settings for Expires header generation. This setting takes effect when Enable Expires is set to "Yes". It can be overridden by Expires By Type. Do not set this default at the server or virtual host level unless you have to, since it will generate Expires headers for all pages. Most of time this should be set at the context level for certain directories that do not change often. If there is no default setting, no Expires header will be generated for types not specified in Expires By Type.

#### Syntax

A|Mseconds
The file will expire after base time(A|M) plus specified seconds. Base time "A" sets the value to the client's access time and "M" to the file's last modified time.

### Expires By Type⇑

#### Description

Specifies Expires header settings for individual MIME types.

#### Syntax

Comma delimited list of "MIME-type=A|Mseconds". The file will expire after base time (A|M) plus specified seconds.
Base time "A" sets the value to the client's access time and "M" to the file's last modified time. MIME-type accepts wildcard "*", like image/*.

### Header Operations⇑

#### Description

Specifies additional response/request headers to be added. Multiple header directives can be added with one directive per line. "NONE" can be used to disable parent header inheritance. If no directive is provided 'Header' is assumed.

#### Syntax

[Header]|RequestHeader [condition] set|append|merge|add|unset header [value] [early|env=[!]variable]

#### Example

set Cache-control no-cache
append Cache-control no-store
Header set My-header cust_header_val
RequestHeader set My-req-header cust_req_header_val

#### Tips

Syntax and usage are similar to Apache's mod_headers directives for supported operations.
The 'Header' directive is is optional and can be excluded or left in when copying rules from elsewhere without issue.

### MIME Type⇑

#### Description

Specifies additional MIME types and mappings for this context. New mappings will override existing mappings under this context and its children contexts.
If you want to show PHP scripts as text files instead of being executed as scripts, just override the .php mapping to MIME type "text/plain".

#### Syntax

MIME-type1 extension extension ..., MIME-type2 extension ... Use comma to separate between MIME types, use space to separate multiple extensions.

#### Example

image/jpg jpeg jpg, image/gif gif

### Force MIME Type⇑

#### Description

When specified, all files under this context will be served as static files with the MIME type specified regardless of file suffix. When set to NONE, inherited force type setting will be disabled.

#### Syntax

MIME type or NONE.

### Default MIME Type⇑

#### Description

When specified, this type will be used when MIME type mapping cannot be determined by the suffix of a document or if there is no suffix. If not specified, the default value application/octet-stream will be used.

#### Syntax

MIME-type

### Index Files⇑

#### Description

Specifies names of index files that will be searched sequentially when a URL is mapped to a directory. You can customize it at the server, virtual host, and context level.

#### Syntax

Comma-delimited list of index filenames.

#### Tips

Only set index files that you need.

### Auto Index⇑

#### Description

Specifies whether to generate a directory index on the fly when index files listed in Index Files are not available in a directory. This option is customizable at the virtual host and context level, and is inherited along the directory tree until it is explicitly overridden. You can customize the generated index page. Please check online wiki How-tos.

#### Syntax

Select from radio box

#### Tips

It is recommended to turn off Auto Index wherever possible to prevent revealing confidential data.

#### See Also

Index Files, Auto Index URI

### Realm⇑

#### Description

Specifies the authorization realm for this context. When specified, a valid username and password must be provided in order to access this context. Authorization Realms are set up in the Virtual Host Security section. This setting uses each realm's Realm Name.

#### Syntax

Select from drop down list

### Authentication Name⇑

#### Description

Specifies an alternative name for the authorization realm for the current context. If not specified, the original realm name will be used. The authentication name is displayed on the browser's login pop-up.

### Require (Authorized Users/Groups)⇑

#### Description

Specifies which user/group can access this context. This allows you to use one user/group database (specified in Realm) across a number of contexts, but only allow certain users/groups from that database to access this context.

#### Syntax

Syntax is compatible with Apache's Require directive. For example:

- user username [username ...]
  Only listed users can access this context.
- group groupid [groupid ...]
  Only users belonging to the listed groups can access this context.

If this setting is not specified, all valid users will be allowed to access this resource.

### Access Allowed⇑

#### Description

Specifies which IPs or sub-networks are allowed to access resources under this context. Together with Access Denied and server/virtual host level access control, accessibility is determined by the smallest scope that a client's IP address falls into.

#### Syntax

Comma-delimited list of IPs/sub-networks.

#### Example

Sub-networks can be written as 192.168.1.0/255.255.255.0, 192.168.1, or 192.168.1.*.

### Access Denied⇑

#### Description

Specifies which IPs or sub-networks are NOT allowed to access resources under this context. Together with Access Allowed and server/virtual host-level access control, accessibility is determined by the smallest scope that a client's IP address falls into.

#### Syntax

Comma-delimited list of IPs/sub-networks.

#### Example

Sub-networks can be written as 192.168.1.0/255.255.255.0, 192.168.1, or 192.168.1.*.

### Authorizer⇑

#### 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

### Add Default Charset⇑

#### Description

Specifies whether to add a character set tag to the "Content-Type" response header, when content type is either "text/html" or "text/plain" without any parameters. When set to Off, this function is disabled. When set to On, either the character set specified by Customized Default Charset or the default "iso-8859-1" will be added.

#### Syntax

Select from radio box

### Customized Default Charset⇑

#### Description

Specifies a character set to be used when Add Default Charset is On. This is optional. The default value is iso-8859-1. This entry has no effect when Add Default Charset is Off.

#### Syntax

Name of a character set.

#### Example

utf-8

### Enable Rewrite⇑

#### 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

### Rewrite Inherit⇑

#### Description

Specifies whether to inherit rewrite rules from parent contexts. If rewrite is enabled and not inherited, rewrite base and rewrite rules defined in this context will be used.

#### Syntax

Select from radio box

### Rewrite Base⇑

#### Description

Specifies the base URL for rewrite rules.

#### Syntax

URL

### Rewrite Rules⇑

#### Description

Specifies a list of rewrite rules at the virtual host level.
Do NOT add any document root level rewrite rules here. If you have any document root level rewrite rules from .htaccess, you should instead create a static context with uri "/" and add the rewrite rules there.
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 LiteSpeed rewrite engine will stop processing rewrite rules after encountering an [L] flag to avoid looping while Apache mod_rewrite will stop processing rewrite rules for the current iteration only. This behavior is similar to that of the [END] flag in Apache mod_rewrite.

The implementation of LiteSpeed's rewrite engine follows 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

### Enable GeoLocation Lookup⇑

#### Description

Specifies whether to enable/disable IP Geolocation lookup. Can be set at server, virtual host, or context level. IP Geolocation is disabled by default when using value "Not Set".

#### Syntax

Select from radio box

#### See Also

Use Client IP in Header, DB File Path,

### php.ini Override⇑

#### Description

Used to overwrite php.ini settings in the current context (Virtual Host level or Context level).
Supported directives are:
php_value
php_flag
php_admin_value
php_admin_flag
All other lines/directives will be ignored.

#### Syntax

Override syntax is similar to Apache, a newline separated list of directives and their values with each directive being prepended by php_value, php_flag, php_admin_value, or php_admin_flag appropriately.

#### Example

php_value include_path ".:/usr/local/lib/php"
php_admin_flag engine on
php_admin_value open_basedir "/home"