+

Search Tips | Advanced Search

Apache rewrite

In this scenario, we can use the rewrite directive to convert an HTTP request into an internal Apache proxy redirect.

The proxy and rewrite modules must be loaded, but as Apache is not really working in proxy mode, all proxy directives can remain commented out.


Before starting

  • Before you start to use this scenario, make sure that we have completed the prerequisite tasks listed in Getting started with IBM MQ Internet Pass-Thru.
  • Install an Apache HTTP server in C:\apache. (If it is installed elsewhere, adjust the paths in the following steps accordingly.)
  • Install IBM Caching Proxy in C:\cp\etc\en_US. (If it is installed elsewhere, adjust the paths in the following steps accordingly.)


About this task

Figure 1. Apache rewrite network diagram

This diagram shows the connection from the IBM MQ client (called client1.company1.com on port 1415) through MQIPT, Caching Proxy, Apache, MQIPT, and finally to the IBM MQ server (called server1.company2.com on port 1414).


Procedure

To use the rewrite directive, complete the following steps:

  1. On the caching proxy, edit C:\cp\etc\en_US\ibmproxy.conf and change the following properties:
    ProxyPersistence ON
    MaxPersistRequest  5000
  2. On the Apache system, edit C:\apache\conf\httpd.conf and set the following properties:
    RewriteEngine on
    RewriteLog logs/rewrite.log
    RewriteLogLevel 9
    RewriteRule ^/mqipt  http://%{HTTP:Host}/mqipt  [P]
    
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule negotiation_module modules/mod_negotiation.so
    LoadModule rewrite_module modules/mod_rewrite.so
    
    start Apache
  3. On the MQIPT 1 system:
    1. Edit mqipt.conf and add the following route definition:
      [route]
      ListenerPort=1415
      Destination=10.100.20.3
      DestinationPort=1415
      HTTP=true
      HTTPProxy=10.9.1.3
      HTTPProxyPort=80
      HTTPServer=10.100.6.7
      HTTPServerPort=8080
    2. Open a command prompt and start MQIPT:
      C:\mqipt\bin\mqipt C:\mqiptHome -n ipt1
      where C:\mqiptHome indicates the location of the MQIPT configuration file, mqipt.conf, and ipt1 is the name to be given to the instance of MQIPT. The following messages indicate that MQIPT has started successfully:
      5724-H72 (C) Copyright IBM Corp. 2000, 2020 All Rights Reserved
      MQCPI001 IBM MQ Internet Pass-Thru V9.2.0.0 starting
      MQCPI004 Reading configuration information from mqipt.conf
      MQCPI152 MQIPT name is ipt1
      MQCPI021 Password checking has been enabled on the command port
      MQCPI011 The path C:\mqiptHome\logs will be used to store the log files
      MQCPI006 Route 1415 has started and will forward messages to :
      MQCPI034 ....server1.company2.com(1414)
      MQCPI035 ....using HTTP
      MQCPI024 ....and HTTP proxy at 10.9.1.3(80)
      MQCPI066 ....and HTTP server at 10.100.6.7(8080)
      MQCPI078 Route 1415 ready for connection requests

  4. On the MQIPT 2 system:
    1. Edit mqipt.conf and add the following route definition:
      [route]
      ListenerPort=1415
      Destination=server1.company2.com
      DestinationPort=1414
    2. Open a command prompt and start MQIPT:
      C:
      cd \mqipt\bin
      mqipt .. -n ipt2
      where .. indicates that the MQIPT configuration file, mqipt.conf, is in the parent directory, and ipt2 is the name to be given to the instance of MQIPT. The following messages indicate that MQIPT has started successfully:
      5724-H72 (C) Copyright IBM Corp. 2000, 2020 All Rights Reserved
      MQCPI001 IBM MQ Internet Pass-Thru V9.2.0.0 starting
      MQCPI004 Reading configuration information from mqipt.conf
      MQCPI152 MQIPT name is ipt2
      MQCPI021 Password checking has been enabled on the command port
      MQCPI011 The path C:\mqipt\logs will be used to store the log files
      MQCPI006 Route 1415 has started and will forward messages to :
      MQCPI034 ....server1.company2.com(1414)
      MQCPI035 ....using MQ protocol
      MQCPI078 Route 1415 ready for connection requests

  5. At a command prompt on the IBM MQ client system, enter the following commands:
    1. Set the MQSERVER environment variable:
      SET MQSERVER=MQIPT.CONN.CHANNEL/tcp/10.9.1.2(1415)
    2. Put a message:
      amqsputc MQIPT.LOCAL.QUEUE MQIPT.QM1
      Hello world
      Press Enter twice after typing the message string.
    3. Get the message:
      amqsgetc MQIPT.LOCAL.QUEUE MQIPT.QM1
      The message, "Hello world" is returned.

Parent topic: Getting started with IBM MQ Internet Pass-Thru

Last updated: 2020-10-04