+

Search Tips   |   Advanced Search

Portal, V6.1


 

Examples of AJAX proxy configurations

The following two examples show sample proxy-config.xml files that use as templates to define your own configurations. Use these samples as a base to write your own AJAX proxy configuration

Example: Generic proxy configuration to access multiple target hosts Use the configuration shown below for applications that need to connect to several different target hosts. For example, this can be a feed reader portlet that can be configured with the feed URL. Accordingly, the configuration defines only one context path mapping element, which is used for all incoming requests. The specified access policy restricts the set of allowed HTTP operations to GET and HEAD. It does not declare any mime type elements, that is, the proxy does not filter the received HTTP responses based on their content type header.

<?xml version="1.0" encoding="UTF-8"?>
<proxy-rules
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:proxy="http://www.ibm.com/xmlns/prod/sw/ajax/proxy-config/1.0">
   <proxy:mapping contextpath="/proxy" url="*" />
   <proxy:policy url="*" acf="none">
      <proxy:actions>
         <proxy:method>GET</proxy:method>
         <proxy:method>HEAD</proxy:method>
      </proxy:actions>
   </proxy:policy>
   <proxy:meta-data>
      <proxy:name>max-connections-per-host</proxy:name>
      <proxy:value>10</proxy:value>
   </proxy:meta-data>
   <proxy:meta-data>
      <proxy:name>max-total-connections</proxy:name>
      <proxy:value>150</proxy:value>
   </proxy:meta-data>
</proxy-rules>

Example: Proxy configuration to access a specific target host In contrast to the example shown above, the second example is meant for applications which connect to only one specific data source. For example, this can be an external REST service. The example shows how to connect to a REST service that offers read and write access to a knowledge base that provides articles. Accordingly, the configuration declares one context path mapping, which maps the context path "/knowledge" to the URL pattern "http://mycompany.com:8081/knowledgebase". Furthermore, the configuration defines two access policies: one to allow anonymous users to access abstracts, and a second one to enable authenticated users to retrieve concrete articles.

<?xml version="1.0" encoding="UTF-8"?>
<proxy-rules
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:proxy="http://www.ibm.com/xmlns/prod/sw/ajax/proxy-config/1.0">
   <proxy:mapping contextpath="/knowledge" url="http://mycompany.com:8081/knowledgebase" />
   <proxy:policy url="http://mycompany.com:8081/knowledgebase/abstracts/*" acf="none">
      <proxy:actions>
         <proxy:method>GET</proxy:method>
         <proxy:method>HEAD</proxy:method>
      </proxy:actions>
   </proxy:policy>
   <proxy:policy url="http://mycompany.com:8081/knowledgebase/articles/*" acf="none">
      <proxy:actions>
         <proxy:method>GET</proxy:method>
         <proxy:method>HEAD</proxy:method>
         <proxy:method>POST</proxy:method>
         <proxy:method>PUT</proxy:method>
         <proxy:method>DELETE</proxy:method>
      </proxy:actions>
      <proxy:cookies>
         <proxy:cookie>LTPA</proxy:cookie>
      </proxy:cookies>
      <proxy:users>
         <proxy:user>AllAuthenticatedUsers</proxy:user>
      </proxy:users>
   </proxy:policy>
</proxy-rules>

 

Parent topic

The proxy-config.xml file