Skip to main content

Using Caché Server Pages with a Remote Web Server

Important:

InterSystems recommends using the Web Gateway, which is an updated and more feature-rich version of the CSP Gateway. The Web Gateway is compatible with Caché and Ensemble starting with version 2017.1. For more information, read the Web Gateway GuideOpens in a new tab in the latest InterSystems IRIS® documentation.

This appendix describes the following configurations using CSP on a remote web server.

Configuring the Web Server and CSP Gateway

This section discusses how to set up a web server and the CSP Gateway to provide access to a CSP application installed on a remote Caché server. The instructions refer to the web server as Machine W and to the computer running Caché as Machine C. The setup includes the following procedures:

  1. Install the CSP Gateway on the Web Server Machine

  2. Configure the CSP Gateway

  3. If Serving Static Files from the Web Server

  4. Configure Web Server Paths

Install the CSP Gateway on the Web Server Machine

Install the CSP Gateway on the web server machine, Machine W, where IIS or Apache is running. See the section “Web Server (CSP) Gateway Installation” in the Caché Installation Guide if you need more detailed information. During the installation process, follow these instructions:

  1. In the Setup Type dialog box, select Web Server and select Next.

  2. Review the installation name, type, and destination directory and, if correct, select Install.

This creates the CSP directory structure on Machine W and creates virtual directory references for the /CSP and /CSP/Bin files.

Configure the CSP Gateway

Next, adjust the CSP Gateway Configuration on Machine W. Although the CSP Gateway configuration information is stored in the csp.ini file, always use the Caché Server Pages Web Gateway Management application to update the configuration:

  1. Navigate to the CSP Web Gateway Management home page by pointing a browser to:

    http://localhost/csp/bin/Systems/Module.cxwOpens in a new tab

    (Bookmarking this URI is helpful). This link is for your external web server, not the Private Web Server supplied with Caché.

    Note that the link above is correct if you are on the same system that the web server is running on using port 80. If are trying to access the CSP Web Gateway Management home page on one system (local system) from another system (remote system), you will be denied access by default. You can access the home page from a remote system in one of two ways: 1) Connect to the home page on the local system and set the System Manager field (under Default Parameters) to the IP address of the remote system. or 2) Edit the csp.ini file on the local system and add the line: System_Manager=remote-system-ip-address

  2. Select Server Access in the left-hand menu. The Caché installation configures a LOCAL server to connect to the Caché instance on the local machine, Machine W.

  3. Create a new server to represent the Caché instance running on the remote machine, Machine C:

    1. Select Add Server.

    2. Enter a name for the server (Machine C for example).

    3. Enter the TCP/IP Address and TCP/IP Port of the remote Caché server on Machine C.

    4. Modify the Connection Security settings to match the level of authentication expected by Machine C for CSP Gateway connections. See the CSP Gateway and Security section in this guide for details.

    5. Select Save Configuration.

  4. Select Application Access in the left-hand menu to associate the path to the CSP application on the remote Caché server, Machine C, with the server configuration previously created for Machine C. The default paths are predefined for / and /csp.

  5. Create a new application path to represent the CSP application running on the remote machine, Machine C. You can either copy an existing configuration (such as /csp) or select Add Application to manually create a new path configuration. The path you create for the application must match that defined for the application in the Caché instance on Machine C.

    For example, the default path to the Management Portal is /csp/sys. If you are creating a new application choose your own path name. For example: /myapp or /csp/myapp. Having created the new path, modify the Default Server parameter for the path such that it takes the value of the Caché server configuration that you previously set up for Machine C.

  6. Finally, save the new path configuration.

If Serving Static Files from the Web Server

If you are planning to serve static files from the web server, create directories on Machine W to represent your application path. These directories exist solely to hold static content such as image files. You do not have to place any CSP files here; they reside on Machine C.

Under the directory install-dir\CSP on Machine W, create \Samples and \User directories. Also create directories to represent other paths which may contain static components referenced in CSP pages. The example in the previous section, requires you to create a directory for \myapp.

Configure Web Server Paths

The application paths in the previous steps correspond to requests for CSP pages in the equivalent locations. For example:

http://domain.com/myapp/login.csp
http://domain.com/csp/myapp/login.csp
http://domain.com/csp/sys/login.csp

Inheritance is applied in a hierarchical fashion. Consider the following request:

http://domain.com/csp/newapp/login.csp

The application path configuration for /csp/newapp is used if it exists. If not, the configuration defined for /csp is used instead.

The CSP Gateway installation procedures configure the hosting web server to recognize the /csp virtual path. Typically, these same settings also apply to directories placed under /csp (/csp/myapp, for example).

If you create a new path (such as in the first example, /myapp), you must configure the web server to recognize this new virtual path. These procedures are different depending on the web server you use. Follow the procedures in the section that applies to your web server:

Add Virtual Directories to IIS

The installation procedure for the CSP Gateway configures the virtual directory /csp for CSP applications. If all of your applications are under this virtual directory (for example, /csp/myapp) and you are not using virtual hosts, you do not need to add virtual directories. The instructions in this section apply specifically to the IIS (Internet Information Services) versions 6 and 7 web server.

Set up the application path resembling /myapp in the previous examples with properties similar to the /csp virtual directory which is automatically created for you during the CSP Gateway installation.

  1. Navigate to the Internet Information Services management dialog box, which is likely accessible from the Administrative Tools menu of the Windows Control Panel.

  2. Expand the folders and right-click Default Web Site.

  3. Point to New and select Virtual Directory to create a new directory record with the following values:

    Alias:                 myapp
    Directory:             C:\cache-install-dir\csp\myapp
    Access Permissions:    Select the Execute check box (on IIS 6 only)
    
  4. Either select Save and Apply all changes, or if you are using the wizard, select Finish.

On IIS 6, you can check as follows: Right-click the virtual directory name under Default Web Site and select Properties. It looks similar to the following figure:

generated description: csp execpermissions

Restart IIS to apply the changes.

Add Aliases to Apache Configurations

If you are using an Apache web server to control a remote Caché server and your application path is altered from the /csp default, you must manually add a corresponding alias to the Apache configuration file pointing to the local CSP directory.

For example, to remotely serve the CSP applications on the Caché instance cache-install-dir on Machine C from the application path defined on the web server, /myapp/csp, add the following alias line to the httpd.conf file on Machine W:

Alias /myapp/csp "C:/cache-install-dir/CSP" 

Restart the Apache web server to apply the changes.

Accessing CSP on Multiple Caché Servers

Read this section if you need to configure a single web server to access a single CSP application on more than one Caché server. Also read this section if you want to use a single web server to access more than one CSP application on more than one remote Caché server.

This section uses the Management Portal as the example application. Adapt these procedures for your own CSP application.

The Management Portal application is usually called with a URL in this format:

http://domain.com/csp/sys/UtilHome.csp

Once you have configured your application as described below, then to access this application on different servers, such as servers called cache1 and cache2,you will include the individual Caché servers names as part of the URLs as follows.

http://domain.com/cache1/csp/sys/UtilHome.csp
http://domain.com/cache2/csp/sys/UtilHome.csp

Changing the Caché Server Name in the URL

You can choose to display the Caché server name in the application path URL or not. If you are content with using the Caché server name in the URL, skip this subsection and proceed to the next subsection called “Configuring the Caché Server for the Application Path”.

If you do not want the Caché server name displayed in the CSP application URL, then follow the procedure in this subsection to create a substitute name.

Use the CSPConfigName parameter of the %System.CSP.SetConfigOpens in a new tab method for each of these servers. This example uses linda as the substitute name for server cache1 and perry as the substitute name for a server cache2. Follow this example using your own servers and substitute names.

In a terminal window on the cache1 server, run:

d $System.CSP.SetConfig("CSPConfigName","linda")

In a terminal window on the cache2 server, run:

d $System.CSP.SetConfig("CSPConfigName","perry")
  1. On cache1, access the CSP Gateway Management page with:

    http://localhost/csp/bin/Systems/Module.cxwOpens in a new tab

  2. Select Server Access. Add server configurations for cache1 and cache2. See the section “Configuring Server Access” for details.

  3. Select Application Access. Create an application path /linda/csp/sys/ with a Default Server of cache1. Create an application path /perry/csp/sys/ with a Default Server of cache2. See the section “Configuring Application Access” for details.

  4. If the web server is IIS then set up virtual directories for /cache1 and /cache2 as described in the Add Virtual Directories to IIS section.

    If using an Apache web server see Add Aliases to Apache Configurations.

To see other CSP global parameters, enter %SYS>d $system.CSP.DisplayConfig()

Configuring the Caché Server for the Application Path

If you are content with using the Caché server name in the URL, follow this procedure. If you do not want the Caché server name displayed in the CSP application URL, then follow the procedure in the preceding subsection “Concealing the Caché Server Name in the URL”

  1. On your first server, access the CSP Gateway Management page with:

    http://localhost/csp/bin/Systems/Module.cxwOpens in a new tab

  2. Select Server Access. Add server configurations for cache1 and cache2. See the section “Configuring Server Access” for details.

  3. Select Application Access. Create an application path /cache1/csp/sys/ with a Default Server of cache1. Create an application path /cache2/csp/sys/ with a Default Server of cache2. See the section “Configuring Application Access” for details.

  4. If the web server is IIS then set up virtual directories for /cache1 and /cache2 as described in the Add Virtual Directories to IIS section.

    If using an Apache web server see Add Aliases to Apache Configurations.

Configuring Apache Virtual Hosts

An alternative method for accessing an application on multiple servers is to use virtual host arrangements. Virtual hosts are a common feature in Apache web server configurations and are straightforward to set up in this server environment. For example, consider two virtual hosts, each listening on a separate TCP port:

http://virtual_host1:81/csp/sys/UtilHome.csp
http://virtual_host2:82/csp/sys/UtilHome.csp

Both virtual_host1 and virtual_host2 are served by the same web server and CSP Gateway.

The following shows the Apache configuration (httpd.conf) for this arrangement:

<VirtualHost virtual_host1:81>
   ServerName virtual_host1
</VirtualHost>

<VirtualHost virtual_host2:82>
   ServerName virtual_host2
</VirtualHost>

Configure the use of these virtual hosts using the CSP Gateway Management application as follows:

  1. Navigate to the Caché Server Pages Gateway Management home page by pointing a browser to:

    http://localhost/csp/bin/Systems/Module.cxw
    
  2. Select Server Access to create a server configuration for cache1 and cache2.

  3. Select Application Access to create the application paths //virtual_host1/csp/sys/ and //virtual_host2/csp/sys/.

    Note the use of the double forward-slash (//) to introduce the virtual host name.

    Set the Default Server for path //virtual_host1/csp/sys/ to be the name of the server configuration set up for cache1 in the previous step.

    Set the Default Server for path //virtual_host2/csp/sys/ to be the name of the server configuration set up for cache2 in the previous step.

  4. No changes are required in the configuration of the two remote Caché servers. The application path for the portal remains as /csp/sys/ in both cases.

See Virtual Hosts Overview for more information.

Virtual Hosts Overview

Virtual hosts are a means through which you can transparently serve applications on one or more instances through a common web server. Each server installation appears to operate as a separate web server.

The differentiating factor in virtual host setups can be one of the following:

  1. Web server IP address — The server hosting the web server is exposed through two IP addresses. For example:

    123.123.123.1 == www.serverA.com
    123.123.123.2 == www.serverB.com
    
    
  2. Web server port — This method is useful for testing different configurations, though it involves including the port number in the request for cases where non-standard TCP ports are used (TCP ports other than 80). For example:

    Web Server TCP Port 80 == www.serverA.com
    Web Server TCP Port 81 == www.serverB.com
    
    
  3. Path — the preferred way of implementing virtual hosts. You register the two names and they translate to a single physical IP address for the web server. For example:

    www.serverA.com == 123.123.123.1
    www.serverB.com == 123.123.123.1
    
    

Regardless of which way you choose, set up a named slot for each Caché installation in the CSP Gateway configuration (it does not need to be the same as the Caché instance name). The superserver port that the CSP Gateway configuration (for each server) is pointing to is what is important.

For example:

www.serverA.com 
www.serverB.com 

Both are served by a single web server installation.

You can implement servers including mixtures of all three. Options 1 and 3 are identical from the browser perspective. You can configure each virtual host to have its own documents root, etc.

To extend the virtual host concept through to CSP, suppose you wish to run the same CSP application through two virtual hosts, but on different Caché instances. For example, one site for testing and another for production.

www.serverA.com/csp/login.csp ==> CacheServerA
www.serverB.com/csp/login.csp ==> CacheServerB

A CSP application’s access to a Caché server is controlled through the CSP Gateway Application Access configuration option. Typically, the following two entries are defined:

/ 
/csp 

The name of the Caché server is associated with these application path definitions:

/ (Default Server == CacheServerA) 
/csp (Default Server == CacheServerA) 

The Gateway allows you to extend this configuration to include the name of a virtual host through which you access the application.

/ (Default Server == CacheServerA) 
/csp (Default Server == CacheServerA) 
//www.serverA.com/csp (Default Server == CacheServerA) 
//www.serverB.com/csp (Default Server == CacheServerB) 

You can then configure a separate Caché server for www.serverA.com/csp and www.serverB.com/csp as shown above. Introduce server names by //, as shown.

The current rules of inheritance apply. For example, if you request www.serverA.com/xxx/yyy.csp, then the Caché server defined for / is ultimately used, unless, you define an ultimate default for serverA as shown below:

/ (Default Server == CacheServerL) 
/csp (Default Server == CacheServerL) 
//www.serverA.com/ (Default Server == CacheServerL) 
//www.serverA.com/csp (Default Server == CacheServerA) 
//www.serverB.com/csp (Default Server == CacheServerB) 

Note:

The servers specified in the CSP Gateway configuration do not necessarily have to be virtual. For example, you can configure a single NSD installation to support several real Apache installations with a different set of Caché servers defined for each one. Further, you can configure each Apache server to support many virtual hosts.

The CSP Gateway identifies the host for the application through the CGI environment variable SERVER_NAME.

FeedbackOpens in a new tab