Setting up Content Handling

This section describes how you can configure and manage content for virtual servers.

Configuring General Settings

Click Content Handling tab > General tab to edit basic content handling settings.

Configuring Directory Listing

Configure the following parameters under the Directory Listing sections:

Field

Description

Directory Listing

You can customize the startup page for an application folder with the following parameters.

Listing Type

You can choose from Fancy/Simple/None

  • Fancy -- Lists all the files in the directories in a special format providing all relevant information about the sub directories and files.

  • Simple -- Lists all the files and sub directories in a simple list based format.

  • None -- This option turns off directory listing. When this option is applied for the virtual server, attempt to access the directory will show an error page.

Error Response

Error response file to use when directory listing is disabled.

Initial Page

Path to the home page file.

Index Files

Provide a list of welcome files or startup pages for the virtual server. Enter comma separated values of files for more than one file

Configuring Parsed HTML/SSI

HTML parsing allows the server to search HTML files for special commands (parse the HTML). Click New button under Parsed HTML/SSI section for configuring the settings. You can use the following fields to create a URI pattern for which HTML Parsing will be enabled:

Field

Description

Applies To

You can either apply the changes to the entire virtual server or the specific URI pattern provided in the New URI field.

Execute Tag

Enabling the exec tag allows the HTML files to execute arbitrary programs on the server. You may not want to allow the exec tag for security or performance reasons.

Parsed Files

Choose which files to parse.

You can choose whether to parse only files with the .shtml extension, or all HTML files, which has an impact on performance. If you are using UNIX/Linux, you can also choose to parse UNIX/Linux files with the execute permission turned on, though that can be unreliable.

Configuring Document Footer

Click New button under Document Footer section for configuring the settings. The following fields allow you to specify a document footer that can be included in your documents. You can include the document footer for the entire virtual server or a specific URI pattern.

Field

Description

Document Footer

You can specify a document footer, which can include the last-modified time, for all the documents in a certain section of the server. This footer works for all files except output of CGI scripts or parsed HTML (.shtml) files.

If you need your document footer to appear on CGI-script output or parsed HTML files, enter your footer text into a separate file and add a line of code or another server-side include to append that file to the page's output.

Applies To

You can either apply the changes to the entire virtual server or the specific URI pattern provided in the New URI field.

MIME Type

Content handling for the document footer works only for files of this MIME type. Default is text/html.

Date Format

Select the date format to be displayed for the timestamp information.

Footer Text

Enter a short text, which will be used as the document footer body text.

Configuring HTTP Compression

Click New button under HTTP Compression section. The following page allows you to administer serving of compressed content. You can enable Pre-compressed content serving or On-Demand compression for the entire virtual server or for a specific URI pattern.

Field

Description

Applies To

You can either apply the changes to the entire virtual server or the specific URI pattern provided in the New URI field.

On-demand Compression

Use this option to enable on-demand compression.

Insert Vary Header

Specifies whether to insert a Vary: Accept-encoding header. If set to True, A Vary: Accept-encoding header is never inserted. If set to False, A Vary: Accept-encoding header is always inserted when a compressed version of a file is selected. The value is set to True by default.

Fragment Size

Specifies the memory fragment size (in bytes) that has to be used by the compression library (zlib) to control the rate of compression (the amount to compress at one time).

Compression Level

Use the drop-down list to specify the level of compression. Choose NONE or a value between 1 and 9. The value 1 yields the best speed; the value 9 the best compression. A middle value provides a compromise between speed and compression.

Configuring Document Directories

The primary document directory (also called the document root) is the central directory where you store all the files you want to make available to remote clients.

You can create a document directory, which is in addition to the primary document directory. By doing this, you can let someone manage a group of documents without giving them access to your primary document root.

ProcedureCreating a New Document Directory

  1. Select the Configuration.

    Select the configuration from the configurations list. Click Configurations tab to get the available configurations.

  2. Select the Virtual Server.

    Select the virtual server for which you need to add a new document directory. Click Virtual Servers tab to get the list of configured virtual servers for the selected configuration.

  3. Click Document Directories tab.

  4. Click New Document Directory button. Configure the following parameters:

Configuring CGI Settings

Sun Java System Web Server allows you to add CGI document directories using the administration console GUI.

To add a new CGI document directory, perform the following tasks:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click Content Handling sub tab and CGI sub tab.

  4. Click New button to add a new CGI document directory.

  5. Provide necessary values for fields URI Prefix and Directory as described in the following table. Click OK button. Click Deployment Pending Link > Deploy to deploy the modified configuration.

The following table describes the CGI parameters.

Table 5 CGI Parameters

Parameter

Description

Prefix

Type the URL prefix to use for this directory. That is, the text you type appears as the directory for the CGI programs in URLs.

For example, if you type cgi-bin as the URL prefix, then all URLs to these CGI programs have the following structure:

http://yourserver.domain.com/cgi-bin/program-name

CGI Directory

In the CGI Directory text field, type the location of the directory as an absolute path. Note that this directory doesn't have to be under your document root. This is the reason that you need to specify a URL prefix.


Note - The URL prefix you specify can be different from the real CGI directory.


User

Specify the name of the user to execute CGI programs as.

Group

Specify the name of the group to execute the CGI programs as.

Chroot

Specify the directory to chroot to before execution begins. (Only for UNIX based systems).

Nice

Specify a nice value, an increment that determines the CGI program's priority relative to the server.

Typically, the server is run with a nice value of 0 and the nice increment would be between 0 (the CGI program runs at same priority as server) and 19 (the CGI program runs at much lower priority than server). While it is possible to increase the priority of the CGI program above that of the server by specifying a nice increment of -1, this is not recommended.

To remove an existing CGI directory, select the CGI directory and click Delete button. To change the URL prefix or CGI directory of an existing directory, Click the directory link.

Copy your CGI programs into the directories you've specified. Remember that any files in those directories will be processed as CGI files, so don't put HTML files in your CGI directory.

For specifying CGI as a file type, perform the following tasks:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click Content Handling sub tab and CGI sub tab.

  4. Click New button under CGI as File Type section.

You can either apply these settings at the virtual server level or restrict it to a specific URI. Configure the rest of the parameters as discussed in the previous table.

The CGI files must have the file extensions .bat, .exe, or .cgi. Any non-CGI files with those extensions are processed by your server as CGI files, causing errors.

Setting up URL Redirection

URL redirection allows you to redirect document requests for one HTTP URL to another HTTP URL. Forwarding URLs or redirection is a method for the server to tell a user that a URL has changed (for example, because you have moved files to another directory or server). You can also use redirection to seamlessly send request for a document on one server to a document on another server.

For example, if you forward http://www.sun.com/info/movies to a prefix film.sun.com, the URL http://www.sun.com/info/movies redirects to http://film.sun.com/info/movies.

Sometimes you may want to redirect requests for all the documents in one subdirectory to a specific URL. For example, if you had to remove a directory because it was causing too much traffic, or because the documents were no longer to be served for any reason, you could direct a request for any one the documents to a page explaining why the documents were no longer available. For example, a prefix on /info/movies could be redirected to http://www.sun.com/explain.html.

You can set URL redirection at the virtual server level.

To configure URL redirection, perform the following steps:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click Content Handling sub tab and URL Redirects sub tab.

  4. Click New button to add a new URL redirect rule.

  5. Provide necessary values for fields described in the following table. Click Save button. You may need to click Apply Changes button for the configuration if needed.

The following table describes the fields required while adding a new URL Redirect rule.

Table 6 Field Description > Adding new URL redirect

Field

Description

Source

URI Prefix -- URI from which the requests should be redirected. All HTTP requests to this URI pattern will be redirected to the URL specified by the Target URL.

Condition -- Instead of providing a URI prefix as source, you can also use regular expression in the condition text field. For example, if you need to redirect requests to a particular URL if the browser is Mozilla, then type $browser = "Mozilla" in the condition field.

The Web Server includes a set of variables predefined by the server, as well as the capability for you to define custom variables. In our example, browser is a pre-defined variable. For a list of available pre-defined variables, see http://docs.sun.com/app/docs/doc/819-2630/6n4thbifj?a=view#gdvaw

You can define custom variables in the server.xml file using the variables element and then refer to those variables from this condition text.

For more information on variables, operators and expression, see the Administrator's Configuration File Reference Guide.

Target URL

URL to which the requests should be redirected. All HTTP requests from the URL specified in the From URL will be redirected to this URL.

URL Type

Fixed. Enabled/Disabled. Fixed URLs are static URLs like a link to an HTML page. Non-Fixed URLs are dynamic URLs with request parameters or URLs with just prefixes.

Configuring Error Pages

You can specify a custom error response that sends a detailed message to clients when they encounter errors from your virtual server. You can specify a file to send or a CGI program to run.

For example, you can change the way the server behaves when it gets an error for a specific directory. If a client tries to connect to a part of your server protected by access control, you might return an error file with information on how to get an account.

Before you can enable a custom error response, you must create the HTML file to send or the CGI program to run in response to an error.

To add a custom error page, follow these steps:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click Content Handling sub tab and Error Pages sub tab.

  4. Click New button to add a custom error page.

    For each error code you want to change, specify the absolute path to the file or CGI that contains the error response.

  5. Click OK to return to the error pages list.

Configuring Reverse Proxy

A reverse proxy is a proxy that appears to be a web server (origin server) to clients but in reality forwards the requests it receives to one or more origin servers. Because a reverse proxy presents itself as an origin server, clients do not need to be configured to use a reverse proxy. By configuring a given reverse proxy to forward requests to multiple similarly configured origin servers, a reverse proxy can operate as an application level software load balancer.


Note - In a typical deployment one or more reverse proxies will be deployed between the browsers and the origin servers.


ProcedureAdding a new Proxy URI

  1. Click Configurations tab and select the configuration.

  2. Click Virtual Servers tab and select the virtual server.

  3. Click Content Handling > Reverse Proxy tab.

  4. Click New Proxy URI button.

    Specify values for the following parameters:

ProcedureTo Configure Reverse Proxy Settings

  1. Click Configurations tab and select the configuration.

  2. Click Virtual Servers tab and select the virtual server.

  3. Click Content Handling > Reverse Proxy tab.

  4. Click URI

    You can edit the following parameters:

Configuring FastCGI

FastCGI is an open extension to CGI (Common Gateway Interface), which is a standard for interfacing external applications with web servers. Like CGI, FastCGI applications run in separate, isolated processes. You can use FastCGI applications to achieve better performance over CGI applications.

The FastCGI Plug-in allows the Sun Java System Web Server to safely work with popular third party dynamic content generation technologies (PHP, Perl, Python, etc.) in a scalable way. The FastCGI Plug-in implements the client side of the FastCGI protocol. This protocol allows producers of dynamic content (and content engines) to implement a common, scalable API that can be utilized by many web servers.

For more information on FastCGI and the SAFs provided by the FastCGI plug-in, see the Sun Java System Web Server Administrator's Guide.

ProcedureTo Add a FastCGI Handler

  1. Click Configurations tab and select the configuration.

  2. Click Virtual Servers tab and select the virtual server.

  3. Click Content Handling > FastCGI tab.

  4. Click New button under FastCGI Enabled URIs table.

    You can edit the following parameters:

Configuring MIME Types

In the HTTP protocol used by web browsers to communicate with web server, the file extension of the URL is not used to determine the type of information that the server will return. Indeed, there may be no file extension at all at the end of the URL. Instead, the web server specifies the correct MIME type using a Content-type: header when it responds to the web browsers HTTP request.

You can configure MIME types at both the configuration level and the virtual server level.

You can view the configured MIME mappings for a virtual server by performing the following tasks:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click Content Handling sub tab and MIME Types sub tab.

The MIME Mappings page has a list of MIME headers and values for the selected configuration. To add a new MIME mapping, perform the following tasks:

  1. Click New button and configure the following properties:

    1. MIME Header -- Select from Content-type, Content-encoding and Content-language.

    2. MIME Value -- Enter the value for the MIME header. For example, For Content-type MIME header, the MIME value could be text/plain, text/html etc.

    3. File Suffix -- File extension for the MIME value. For example, For text/html MIME value, the file extension could be htm/html.

  2. Click Save button to save the new MIME mapping.