1
0
-1

We are currently running two tomcat servers on our machine, one for 9.7 and one fo 10.3. 

9.7 on port 8080, 10.3 on port 8084. 

In order to remove the port numbers from the URL, I am trying to configure the IIS isapi_redirect. I have configured the jakarta folder in IIS to point to the 10.3 tomcat installation folder and configured the properties files as follows. 

workers.properties

#
# Simple workers configuration file
# Check the JK Documentation of Tomcat for more information
#

ps=\

# List all workers
worker.list=defworker,support

# Redefining the worker named defworker of type ajp13
worker.defworker.port=8080
worker.defworker.host=localhost
#worker.defworker.type=ajp13
worker.defworker.lbfactor=1
# Specify the size of the open connection cache.
#worker.defworker.cachesize

# Specifies the load balance factor when used with a load balancing worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=defworker

# Redefining the worker named defworker of type ajp13
worker.support.port=8084
worker.support.host=localhost
#worker.support.type=ajp13
worker.support.lbfactor=1
# Specify the size of the open connection cache.
#worker.support.cachesize


uriworkermap.properties

#
# Simple uri worker map configuration file
# Check the JK Documentation of Tomcat for more information
#

#default.worker=defworker
#uniface.worker=defworker
#support.worker=support

# --- Worker mappings for Uniface ---
/uniface/*=defworker

/support/*=support


a correctly working URL for the 10.3 install is SERVER:8084/webapp/support/main, and I have copied the webapp.xml to support.xml so SERVER:8084/support/support/main also works. 

When I try any combination of what I think should be the URLs to use the IIS, I get errors in the isapi_redirect.log of 

[Wed Jan 29 14:05:54.015 2020] [9452:11940] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1313): wrong message format 0x4854 from 127.0.0.1:8084
[Wed Jan 29 14:05:54.026 2020] [9452:11940] [error] ajp_get_reply::jk_ajp_common.c (2176): (support) Tomcat is down or refused connection. No response has been sent to the client (yet)
[Wed Jan 29 14:05:54.033 2020] [9452:11940] [info] ajp_service::jk_ajp_common.c (2673): (support) sending request to tomcat failed (recoverable), because of protocol error (attempt=1)
[Wed Jan 29 14:05:54.145 2020] [9452:11940] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1313): wrong message format 0x4854 from 127.0.0.1:8084
[Wed Jan 29 14:05:54.157 2020] [9452:11940] [error] ajp_get_reply::jk_ajp_common.c (2176): (support) Tomcat is down or refused connection. No response has been sent to the client (yet)
[Wed Jan 29 14:05:54.165 2020] [9452:11940] [info] ajp_service::jk_ajp_common.c (2673): (support) sending request to tomcat failed (recoverable), because of protocol error (attempt=2)
[Wed Jan 29 14:05:54.173 2020] [9452:11940] [error] ajp_service::jk_ajp_common.c (2693): (support) connecting to tomcat failed.
[Wed Jan 29 14:05:54.185 2020] [9452:11940] [error] HttpExtensionProc::jk_isapi_plugin.c (2327): service() failed with http error 502

And the localhost_access_log of 

127.0.0.1 - - [29/Jan/2020:14:05:54 +0000] "-" 400 -


Using SERVER/support vs SERVER/uniface seems to successfully change which copy of Tomcat the logs are added to, so I THINK the worker properties are pointing to the right internal servers. 

So. 

  1. Can anyone tell me what the 'correct' URL to translate SERVER:8084/webapp/support/main to go via IIS as per the above files is? 
  2. Are the above files 'right'? 


Help!


Iain

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Ian

      Peter's solution would be a good alternative to avoid using IIS, however, if you still want to use isapi redirect then here's some suggestions

      The files look fine, however I noticed you commented the worker.type=ajp13. I believe this is actually the 'protocol' that is used by the isapi_redirect, and it has a separate connector configuration in (both) your server.xml. By default the port number used for this connector is 8009, however, in my case for example it is 8083:

          <!-- Define an AJP 1.3 Connector on port 8083 -->
          <Connector port="8083" protocol="AJP/1.3" redirectPort="8081" />
      
      

      if you then point the worker.port to this connector, it should work

      worker.defworker.port=8083
      worker.defworker.host=localhost
      worker.defworker.type=ajp13
      worker.defworker.lbfactor=1

      As for the the URL;

      let's assume the following:

      Tomcat uniface appliction URL -       http://localhost:8084/webapp/support/main

      IIS website                                         http://localhost/applications

      uriworkermap.properties:                  /applications/*=defworker

      Then basically you should replace * with the tomcat uri except the host part, so something like this:

      http://localhost/applications/webapp/support/main

      Hopefully this helps, 

      Best regards

      Erik

      1. Iain Sharp

        Okay, so I think I get what I did wrong, I changed the ports in the workers to point to the tomcat ports, I need to change them to point to ajp13 ports, which then re-direct to the tomcat ports. 

        I'm going to need to draw this out to explain it to my support engineers.... 

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hello Iain


      Do you really need IIS ?

      Tomcat also has rewriting url options.


      I copy some info below:

      Documentation regarding rewriting in Tomcat:
      host
      https://tomcat.apache.org/tomcat-9.0-doc/config/host.html
      valve
      https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html
      rewrite rules
      https://tomcat.apache.org/tomcat-9.0-doc/rewrite.html

      In D:\apache-tomcat-9.0.30\conf file server.xml I opened up a valve
      <Host name="mymachine.mydomain"  appBase="webapps_prod" unpackWARs="false" autoDeploy="false">
        <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
        <!-- Access log processes all example. Documentation at: /docs/config/valve.html
        Note: The pattern used is equivalent to using pattern="common" -->
       
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="mymachine_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>

      In D:\apache-tomcat-9.0.30\conf\Catalina\mymachine.mydomain file rewrite.config with rules:
      Simple examples
      RewriteCond  %{REQUEST_URI}  ^/webtest97/(.+)/(.+)/$
      RewriteRule ^/(.+[^/])/$ http://mymachine.mydomain:8080/$1 [R=301,L]
      RewriteCond  %{REQUEST_URI}  ^/webtest10302/(.+)/(.+)/$
      RewriteRule ^/(.+[^/])/$ http://mymachine.mydomain:8084/$1 [R=301,L]

      Other more complicated examples
      RewriteCond %{REQUEST_URI} ^/music$
      RewriteRule ^/start$ /messenger/wrd/musicmain [L]
      RewriteCond %{REQUEST_URI} ^/start$
      RewriteRule ^/start$ /messenger/wrd/eimagedsp [L]
      RewriteCond %{HTTP_REFERER} !(.*)/music(.*)$
      RewriteCond %{HTTP_REFERER} !(.*)/messenger(.*)$
      RewriteRule ^(.*)$ /error.htm [L]
      RewriteCond %{REQUEST_URI} ^/(webserver|css|common|img|images|dspjs|index.htm|error.htm)(.*)$
      RewriteRule ^(.*)$ /messenger$1 [L]
      RewriteCond %{HTTP_REFERER} (.*)/start(.*)$
      RewriteCond %{REQUEST_URI} ^/(.*)$
      RewriteRule ^(.*)$ /messenger/wrd$1 [L]
      RewriteCond %{HTTP_REFERER} (.*)/music(.*)$
      RewriteCond %{REQUEST_URI} ^/(.*)$
      RewriteRule ^(.*)$ /messenger/wrd$1 [L]
      RewriteCond %{HTTP_REFERER} (.*)/messenger(.*)$
      RewriteCond %{REQUEST_URI} ^/(.*)$
      RewriteRule ^(.*)$ /messenger/wrd$1 [L]
      messenger.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context override="true" swallowOutput="true" useNaming="false" docBase="D:\apache-tomcat-9.0.2\webapps_prod\messenger">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="uniface-messenger-" suffix=".log" pattern="common"/>
      <!--
        <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
      -->
        <Manager pathname=""/>
      </Context>


      and some xml files to specify where to find what
      messenger#webserver.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context docBase="D:\uniface\installations\10302\uniface\webapps\uniface\webserver">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="messenger-webserver-" suffix=".log" pattern="webserver"/>
      </Context>
      messenger#common.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context docBase="D:\uniface\installations\10302\uniface\webapps\uniface\common">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="messenger-common-" suffix=".log" pattern="common"/>
      </Context>
      In messenger#css.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context docBase="D:\uniface\installations\10302\uniface\webapps\uniface\css">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="messenger-css-" suffix=".log" pattern="css"/>
      </Context>
      In
      messenger#dspjs.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context docBase="D:\uniface\installations\10302\uniface\webapps\uniface\dspjs">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="messenger-dspjs-" suffix=".log" pattern="dspjs"/>
      </Context>
      messenger#images.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <Context docBase="D:\uniface\installations\10302\uniface\webapps\uniface\images">
        <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="messenger-images-" suffix=".log" pattern="images"/>
      </Context>


      Best regards
      Peter Beugel
      Sr. Technical Support Analyst
      Uniface B.V.
      Hoogoorddreef 60,
      1101 BE Amsterdam, The Netherlands
      Tel.: 00800-78776788 (00800-SUPPORTU)
      Email: customer.support@uniface.com

      1. Iain Sharp

        The most important part is (as far as I am concerned) to remove the ":8080" from the URL, I might want to use the renaming part later to tidy up the folder names (although I'm fairly happy with those), it's that I want the URL to be 

        SERVER/support/wrd/main 

        not 

        SERVER:8080/support/wrd/main

        And I cannot guarantee that my customers won't also need IIS (for sharepoint etc) and therefore I must have a config where both can share the same URL. 

      CommentAdd your comment...