Context
In LiteSpeed web server, context is a set of resources that can be located by URLs with a common parent URL. The common parent URL is the ID of the context. A web site is comprised of contexts, for example, "/" is the root Context mapped to the document root of a web site; "/cgi-bin/" is Context dedicated to CGI applications. If you think your web site as a URL tree, then every branch is a context, which can be identified by the URL of the branching node. A context should be explicitly defined for the following purposes:
  • To access file system outside of the document root.
  • To block access to certain resources.
  • To setup user level authentication for certain resources.
  • To create mount points for external processors.
  • To redirect requests to another location.
 
Table of Contents
General Context URI   Root   Accessible   Enable Expires   Expires Default   MIME Type   Force MIME Type   Default MIME Type   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   Add Default Charset   Customized Default Charset   
Java Web App Context URI   Location   Servlet Engine   Enable Expires   Expires Default   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   Add Default Charset   Customized Default Charset   
Servlet Context URI   Servlet Engine   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   Add Default Charset   Customized Default Charset   
Fast CGI Context URI   Fast CGI App   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   Add Default Charset   Customized Default Charset   
Proxy Context URI   Web Server   Add Default Charset   Customized Default Charset   
CGI Context URI   Path   Allow Set UID   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   Add Default Charset   Customized Default Charset   
Redirect Context URI   External Redirect   Status Code   Destination URI   Allow Override   Realm   Authentication Name   Required   Access Allowed   Access Denied   
 
General ContextGo to top
Description: General context is used to bring in files that outside of the document root, like Apache's Alias directive. It can also be used to protect a particular directory (either inside or outside of the document root) using authorization realms. It can also block access for a special directory that may contain sensitive data under the document root.
URIGo to top
Description: Specifies the URI for this context. 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. For examples, a plain URI like /examples/ with Root 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 Root to /home/$1/public_html$2, a request URI /~john/foo/bar.html will map to file /home/john/public_html/foo/bar.html.
Syntax: URI
Apply: On the fly with reload.
RootGo to top
Description: Specifies the corresponding location of this context in the file system. It can be an absolute path or relative path to $SERVER_ROOT, $VH_ROOT and $DOC_ROOT. $DOC_ROOT is the default relative path, and can be omitted. If the URI contains regular expression, the path can reference the matched variables such as $1, $2.
Syntax: path
Apply: On the fly with reload.
AccessibleGo to top
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
Apply: On the fly with reload.
Enable ExpiresGo to top
Description: Specifies whether to generate Expries header for static files. If enabled, 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 the virtual host settings and virtual host settings will override the server settings.
Syntax: Select from radio box
Apply: On the fly with reload.
Expires DefaultGo to top
Description: Specifies default settings for Expires header generation. This setting is effective when Enable Expires is set. It can be overridden by Expires By Type. Do not set this default at server or virtual host level unless you have to, since it will generate Expires header for all pages. Most of time this is set at context level for certain directories that do not change often. If there is no default settings, no Expires header will be generated for types not specified in Expires By Type.
Syntax: A|Mseconds
After base time(A|M) plus specified seconds, it will expire. Base time "A" means the client's access time and "M" means the file's last modified time.
Apply: On the fly with reload.
MIME TypeGo to top
Description: Specifies additional MIME types and mappings for this context. New mappings will override existing mappings under this context and its children contexts.
Example:
image/jpg jpeg jpg, image/gif gif
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.
Apply: On the fly with reload.
Force MIME TypeGo to top
Description: When specified, all files under this context will be served as static files with the MIME type specified regardless file suffix. When set to NONE, inherited force type setting will be disabled.
Syntax: MIME-type|NONE
Apply: On the fly with reload.
Default MIME TypeGo to top
Description: When specified, this type will be used when MIME type mapping can not be determined by the suffix of a document or no suffix. If not specified, default value application/octet-stream will be used.
Syntax: MIME-type
Apply: On the fly with reload.
Allow OverrideGo to top
Description: Specifies what directives in an access control file is allowed. An access control file can be placed in a directory to control the accessibility to files under that directory.
When nothing is checked, inherited default settings will be used. When nothing but "None" is checked, access control file will be ignored.
When Access Control is checked, directives "Order", "Allow" and "Deny" are allowed.
When Authentication is checked, directives "AuthGroupFile", "AuthName", "AuthType", "AuthUserFile", "Require" are allowed.
Allow Override configuration is available in three levels: server level, virtual host level and context level. If server level configuration is not checked, the controlled directives will be disabled for the whole server no matter whether it is enabled or not at lower levels. If server level is enabled, virtual host will inherit same settings by default, similarly context level will inherit virtual host settings. In other words, lower level can disable a setting which is enabled by upper level, but cannot enable a setting which is disabled by upper level.
Syntax: Select from checkbox
Apply: On the fly with reload.
Tips: [Performance] If no need for access control files, uncheck all.
RealmGo to top
Description: Specifies the authorization realm for this context. When specified, a valid user name and password must be provided in order to access this context. Authorization Realms were set up in Virtual Host Security section. Here only use its Name.
Syntax: Select from drop down list
Apply: On the fly with reload.
Authentication NameGo to top
Description: Specifies an alternative name of the authorization realm for current context. If it is not specified, the original realm name will be used. Authentication name is displayed on the browser'slogin popup.
Apply: On the fly with reload.
RequiredGo to top
Description: Specifies which user/group can access this context. With this directive, a large user database can be shared among contexts with different levels of permission.
Syntax: Syntax is compatible with Apache, valid syntaxes are < ul>
  • user username [username ...]
    Only listed users can access this context;
  • group groupid [groupid ...]
    Only users belong to listed groups can access this context.
  • If it is not specified, all valid users can access this resource.
    Apply: On the fly with reload.
    Tips: user username [username ...] or group groupid [groupid ...]
    Access AllowedGo to top
    Description: Specifies which IP or sub-network is allowed to access resource under this context. Together with Access Denied and server/vhost level access control, the accessibility is determined by the smallest scope that client's IP address falls into. This is only effective when Context Access Control is enabled in Virtual Host Security section.
    Syntax: comma-separated list of IP/sub-network. sub-network can be like 192.168.1.0/255.255.255.0, 192.168.1 or 192.168.1.*.
    Apply: On the fly with reload.
    Access DeniedGo to top
    Description: Specifies which IP or sub-network is NOT allowed to access resource under this context. Together with Access Allowed and server/vhost level access control, the accessibility is determined by the smallest scope that client's IP address falls into. This is only effective when Context Access Control is enabled in Virtual Host Security section.
    Syntax: comma-separated list of IP/sub-network. sub-network can be like 192.168.1.0/255.255.255.0, 192.168.1 or 192.168.1.*.
    Apply: On the fly with reload.
    Add Default CharsetGo to top
    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 parameter. When set to Off, this function is disabled. When set to On, either character set specified by Customized Default Charset or the default "iso-8859-1" will be added.
    Syntax: Select from radio box
    Apply: On the fly with reload.
    Customized Default CharsetGo to top
    Description: Specifies a character set to be used when Add Default Charset is On. This is optional. Default value is iso-8859-1. This entry has no effect when Add Default Charset is Off.
    Syntax: name of a character set, like utf-8
    Apply: On the fly with reload.
    Java Web App ContextGo to top
    Description: Most servlet engine has its own built-in HTTP server, but it cannot serve static content as fast as LiteSpeed web server does. In order to improve the overall performance, LiteSpeed web server can be configured as a gateway server, which serves static content and forwards other requests to servlet engine.
    Without Java web app context, multiple contexts have to be created, including a general context that matches the root directory of the web application, servlet contexts for each respective servlet defined in the web application's configuration file - WEB-INF/web.xml. It is awkward and troublesome. Java web app context is introduced to eliminate this hassle by importing a Java web application with only one context configuration. With java web app context, all required contexts are created automatically based on web application's configuration file.
    There are a couple points you need to remember:
    • If the web application is packed into a war file, the war file must be expanded, the web server cannot access files in compressed archive.
    • A Script Handler for .jsp files should be defined as well.
    • For same resources, the same URL should be used no matter whether it is accessed through LiteSpeed web server or through the servlet engine's built-in HTTP server.
      For example, the "examples" web application that comes with Tomcat should be imported. Tomcat 4.1 is installed under /opt/tomcat, files of "examples" web application is located at /opt/tomcat/webapps/examples/, through Tomcat's built-in HTTP server "examples" web application is accessed with URI like /examples/***. In order to use the same URI to access it, the context should be configured with: URI = /examples/, Root = /opt/tomcat/webapps/examples/.
    URIGo to top
    Description: Specifies the URI for this context. URI should start with a "/". If a URI is ended with a "/", then this context will include all sub-URIs under this URI.
    Syntax: URI
    Apply: On the fly with reload.
    LocationGo to top
    Description: Specifies the directory that contains the files for this web application. This is the directory containing the "WEB-INF/web.xml".
    Syntax: path
    Apply: On the fly with reload.
    Servlet EngineGo to top
    Description: Specifies the name of the servlet engine that serves this web application. Servlet engines are predefined in External Applications section, which can either be at server level or at virtual host level.
    Syntax: Select from drop down list
    Apply: On the fly with reload.
    Servlet ContextGo to top
    Description: A single servlet can be imported through servlet context. Just specifies the URI for the servlet and the name of the servlet engine. You only need to use this when you do not want to import the whole web application or you want to protect different servlets with different authorization realms. The URI has the same requirement as in Java Web App Context.
    Fast CGI ContextGo to top
    Description: Fast CGI application cannot be used directly. It must be either configured as a script handler or mapped to a URL through Fast CGI context. A fast CGI context will associate a URI with a fast CGI application.
    Fast CGI AppGo to top
    Description: Specifies the name of the Fast CGI application. It is predefined in External Applications section, which can be at server level or at virtual host level.
    Syntax: Select from drop down list
    Apply: On the fly with reload.
    Proxy ContextGo to top
    Description: Proxy context enables this virtual host as a transparent reverse proxy server. Proxy server could be running in front of any web server or application server that supports HTTP protocol. External web server has to be predefined in External Applications.
    Web ServerGo to top
    Description: Specifies the name of the external web server. It is predefined in External Applications section, which can be at server/virtual host level.
    Syntax: Select from drop down list
    Apply: On the fly with reload.
    CGI ContextGo to top
    Description: CGI context defines one CGI script or a group of CGI scripts. CGI scripts can be either inside or outside of the document root. When a file under the CGI directory is requested, the web server will always try to execute it as a CGI script, no matter it is executable or not. In this way, file content is always protected under CGI context. It is recommended that you put all your CGI scripts in a directory and set up a CGI context.
    PathGo to top
    Description: Specifies the location of CGI scripts. Path can be a directory that contains a group of CGI scripts, like $VH_ROOT/myapp/cgi-bin/. In this case, context URI must end with "/" like /app1/cgi/. Path can also specify only one CGI script, like $VH_ROOT/myapp/myscript.pl with corresponding URI /myapp/myscript.pl.
    Syntax: path
    Apply: On the fly with reload.
    Allow Set UIDGo to top
    Description: Specifies whether set UID bit is allowed for CGI scripts. If set UID bit is allowed and the set UID bit is on for a CGI script, no matter which user the CGI script was started on behalf of, user id of the CGI process will switch to the user id of the owner of the CGI script.
    Default is false.
    Syntax: Select from radio box
    Apply: On the fly with reload.
    Tips: [Security] Do not allow set UID CGI script whenever possible, it could become a serious security problem.
    Redirect ContextGo to top
    Description: A Redirect Context can be used to forward one URI or a group of URI to another location. The destination URI can be either on the same web site or an absolute URI pointing to another web site.
    External RedirectGo to top
    Description: Specifies whether this redirect is external. For external redirection, Status Code may be specified and Destination URI can start either with "/" or "http(s)://". For internal redirection, Destination URI must start with "/".
    Apply: On the fly with reload.
    Status CodeGo to top
    Description: Specifies the response status code of the external redirection. If the status code is between 300 and 399, Destination URI can be specified.
    Syntax: Select from drop down list
    Apply: On the fly with reload.
    Destination URIGo to top
    Description: Specifies the target location of the redirection. If this redirected URI maps to a URI in another redirect context, it will be redirected again. This URI can either be a relative URI on the same web site starting with "/", or an absolute URI pointing to different web site starting with "http(s)://". If the URI contains regular expression, the destination can reference the matched variables such as $1, $2.
    Apply: On the fly with reload.