Topic
  • 18 replies
  • Latest Post - ‏2012-03-03T16:35:07Z by Dhar_Abhay
SystemAdmin
SystemAdmin
3908 Posts

Pinned topic URL redirection

‏2011-12-24T14:40:10Z |
Hi,
I am new to Websphere and IBM httpserver, so basically dont have a much insight on IBM httpserver. Request your kind help

I have a requirement to re-direct requests coming into my IBM httpserver to another application server , if the incoming request is of a certain format.

Incoming request :- http://<host_name>/egi/abc/servlet? . If the request contains egi/abc/servlet , then the <host_name> parameter needs to be modified and the request should be routed.

I have made the below changes to the hosts file and httpd.conf file in Httpserver

Hosts file
10.10.25.131 bsfcod02

Httpd.conf file -
LoadModule rewrite_module modules/mod_rewrite.so

NameVirtualHost fcwebdev.bsf.com:8088

<VirtualHost fcwebdev:8088>
ServerName fcwebdev:8088
DocumentRoot "/usr/IBM/HTTPServer/htdocs"
RewriteEngine on
RewriteRule ^/http://fcwebdev:8088/ http://10.10.25.131/
</VirtualHost>

It doesnt seem to work (the redirection part) and the possible reason for this could be that Httpserver is not looking into <VirtualHost> tag .
Please help me out in resolving this issue. Any pointers to the same will be appreciated...
thanks in advance.

-Abhay
Updated on 2012-03-03T16:35:07Z at 2012-03-03T16:35:07Z by Dhar_Abhay
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-24T15:19:19Z  
    RewriteRule matches against the path component of the URL, not the entire URL, so your rule never matches.

    I suggest using *:8080 in your VirtualHost as well -- hostnames are confusing if not necessary.

    But, I have no idea what you intended to happen to the URL that matches. You just say it should be "routed". Do you mean it should return a redirect to the client? What complete URL should it redirect to?
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-24T15:28:39Z  
    RewriteRule matches against the path component of the URL, not the entire URL, so your rule never matches.

    I suggest using *:8080 in your VirtualHost as well -- hostnames are confusing if not necessary.

    But, I have no idea what you intended to happen to the URL that matches. You just say it should be "routed". Do you mean it should return a redirect to the client? What complete URL should it redirect to?
    RewriteRule matches against the path component of the URL, not the entire URL, so your rule never matches.

    I suggest using *:8080 in your VirtualHost as well -- hostnames are confusing if not necessary.

    But, I have no idea what you intended to happen to the URL that matches. You just say it should be "routed". Do you mean it should return a redirect to the client? What complete URL should it redirect to?

    Eric,
    Thanks for your reply.
    Apologies for the message brevity earlier. I am new to IBM Httpserver, so please pardon my little understanding .

    • My requirement is that if the URL string matches, i need to redirect the incoming request to a application server. This server sits inside another V-LAN and does not have its own webserver.

    If the incoming request is - http://<host_name>/egi/servlet/egigate?keepaliveURL
    then only the host_name will change , the request will be forwarded to the application server , after changing the <Host_name>.

    Thus the request redirecting part.
    I am also not sure, if changes in the httpd.conf will satisfy my requirements.
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-25T07:24:01Z  
    RewriteRule matches against the path component of the URL, not the entire URL, so your rule never matches.

    I suggest using *:8080 in your VirtualHost as well -- hostnames are confusing if not necessary.

    But, I have no idea what you intended to happen to the URL that matches. You just say it should be "routed". Do you mean it should return a redirect to the client? What complete URL should it redirect to?

    Eric,
    Thanks for your reply.
    Apologies for the message brevity earlier. I am new to IBM Httpserver, so please pardon my little understanding .

    • My requirement is that if the URL string matches, i need to redirect the incoming request to a application server. This server sits inside another V-LAN and does not have its own webserver.

    If the incoming request is - http://<host_name>/egi/servlet/egigate?keepaliveURL
    then only the host_name will change , the request will be forwarded to the application server , after changing the <Host_name>.

    Thus the request redirecting part.
    I am also not sure, if changes in the httpd.conf will satisfy my requirements.
    Any pointers any one.. please help
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-25T10:06:39Z  
    Any pointers any one.. please help
    Did it ... yes
    Merry Xmas Everyone...

    <VirtualHost <HOST>:8088>
    ServerName <HOST>:8088
    DocumentRoot "/usr/IBM/HTTPServer/htdocs"
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.<HOST>:8088\egi\servlet\egigate? NC
    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{SERVER_PORT} !^8080$
    RewriteRule ^/egi/(.*) http://<HOST>:8080/egi/$1 L,R
    </VirtualHost>

    Is the entry i added... thanks eric for your response. i had to read a lot , but finally cracked it.
    Merry Christmas and have a prosperous new yr
  • Sunit
    Sunit
    199 Posts

    Re: URL redirection

    ‏2011-12-26T14:56:46Z  
    Any pointers any one.. please help
    Looks like what you are trying to achieve is to get the IBM HTTP Server to "Front" or "proxy" the J2EE application.

    You need to install WAS plugin for IHS for this.

    • Sunit
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-27T10:27:25Z  
    • Sunit
    • ‏2011-12-26T14:56:46Z
    Looks like what you are trying to achieve is to get the IBM HTTP Server to "Front" or "proxy" the J2EE application.

    You need to install WAS plugin for IHS for this.

    • Sunit
    WAS plugin for IHS is installed for our application .. I am trying to redirect the request coming into my HTTP server to a tomcat server.
    This server does not have its own webserver and thus the redirection part.
    But after enabling the rule in httpd.conf in UAT, i have doubts whether the same will work in production env

    Doubts ->
    Browser initiates the req -> the req is recvd at webserver and is redirected from the webserver to the tomcat app server .. 1)now will the response come via the webserver ?? or 2)will it go directly from tomcat app server to browser ??

    1. if the response is going via the webserver .. the response URL will now be the appserver ip address/hostname in the URL address bar ...

    Is there any way to modify the appserver hostname to actual webserver ... so that user thinks that he is on the actualbanks website ....?

    -Abhay
    happy new year
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-27T11:41:41Z  
    WAS plugin for IHS is installed for our application .. I am trying to redirect the request coming into my HTTP server to a tomcat server.
    This server does not have its own webserver and thus the redirection part.
    But after enabling the rule in httpd.conf in UAT, i have doubts whether the same will work in production env

    Doubts ->
    Browser initiates the req -> the req is recvd at webserver and is redirected from the webserver to the tomcat app server .. 1)now will the response come via the webserver ?? or 2)will it go directly from tomcat app server to browser ??

    1. if the response is going via the webserver .. the response URL will now be the appserver ip address/hostname in the URL address bar ...

    Is there any way to modify the appserver hostname to actual webserver ... so that user thinks that he is on the actualbanks website ....?

    -Abhay
    happy new year
    You'll need to do some basic homework and understand the difference between redirection and reverse proxying.

    If you're looking to frontend tomcat, you're better off with a vanilla copy of Apache and not IHS. You won't get any support for front-ending tomcat with IHS anyway.
  • SystemAdmin
    SystemAdmin
    3908 Posts

    Re: URL redirection

    ‏2011-12-27T15:13:09Z  
    You'll need to do some basic homework and understand the difference between redirection and reverse proxying.

    If you're looking to frontend tomcat, you're better off with a vanilla copy of Apache and not IHS. You won't get any support for front-ending tomcat with IHS anyway.
    Hi eric and sunit,
    Thanks for the replies.. Finally able to understand that after httpserver returns a 302 response to browser for redirection. The browser will initiate a request with the changed URL.

    Sunit,
    Please share some more info on the plugin on IHS and WAS ? I am new to WAS and JAVA, so request you to please reply in layman terms.
    -Abhay
  • Sunit
    Sunit
    199 Posts

    Re: URL redirection

    ‏2011-12-29T13:33:26Z  
    Hi eric and sunit,
    Thanks for the replies.. Finally able to understand that after httpserver returns a 302 response to browser for redirection. The browser will initiate a request with the changed URL.

    Sunit,
    Please share some more info on the plugin on IHS and WAS ? I am new to WAS and JAVA, so request you to please reply in layman terms.
    -Abhay
    Abhay,

    There is plenty of material available on the web on this subject.

    WAS plugin for a web server (in this case IHS) is a custom IBM supplied module that is configured with the server. It reads a XML config file that tells it which context roots should be forwarded to WAS and which should be handled by the web server itself. This is like proxy but with load balancing, session affinity built in (with WAS ND).

    So the web browser talks to the web server which in turn talks to WAS application. This among other things allows you to place your HTTP server in DMZ and application server (WAS) in the secure intranet.

    • Sunit
  • Dhar_Abhay
    Dhar_Abhay
    12 Posts

    Re: URL redirection

    ‏2012-02-19T15:09:01Z  
    • Sunit
    • ‏2011-12-29T13:33:26Z
    Abhay,

    There is plenty of material available on the web on this subject.

    WAS plugin for a web server (in this case IHS) is a custom IBM supplied module that is configured with the server. It reads a XML config file that tells it which context roots should be forwarded to WAS and which should be handled by the web server itself. This is like proxy but with load balancing, session affinity built in (with WAS ND).

    So the web browser talks to the web server which in turn talks to WAS application. This among other things allows you to place your HTTP server in DMZ and application server (WAS) in the secure intranet.

    • Sunit
    Hi Sunit,
    After a lot of experiments , i am stll unable to re-direct/forward the request from my server(SERVER A) to the other server(SERVER B).

    Maybe i was unable to explain myself earlier , but my main requirement is that WAS using some plugin/servlet/configurationfile (anything) should forward the incoming HTTP request to another server(SERVER B). This server is not exposed to a public IP.

    The plugin/servlet/configurationfile should receive the response also and forward to browser.

    I tried doing this using servlets - requestdispatcher.forward , but in our case the the other application on SERVER B , is proprietary and cannot be hosted on our server.
    -please help me!
  • gas
    gas
    44 Posts

    Re: URL redirection

    ‏2012-02-20T09:40:12Z  
    Hi Sunit,
    After a lot of experiments , i am stll unable to re-direct/forward the request from my server(SERVER A) to the other server(SERVER B).

    Maybe i was unable to explain myself earlier , but my main requirement is that WAS using some plugin/servlet/configurationfile (anything) should forward the incoming HTTP request to another server(SERVER B). This server is not exposed to a public IP.

    The plugin/servlet/configurationfile should receive the response also and forward to browser.

    I tried doing this using servlets - requestdispatcher.forward , but in our case the the other application on SERVER B , is proprietary and cannot be hosted on our server.
    -please help me!
    Hi,

    If your server is 3rd party (not WAS), then you rather use mod_proxy, not a WebSphere Plugin.

    Check this page how to configure Apache/IHS to proxy requests to backend servers.
    Do not use any java code (servlets/jsp on WAS), but directives on IHS (httpd.conf).
  • Dhar_Abhay
    Dhar_Abhay
    12 Posts

    Re: URL redirection

    ‏2012-02-20T17:06:01Z  
    • gas
    • ‏2012-02-20T09:40:12Z
    Hi,

    If your server is 3rd party (not WAS), then you rather use mod_proxy, not a WebSphere Plugin.

    Check this page how to configure Apache/IHS to proxy requests to backend servers.
    Do not use any java code (servlets/jsp on WAS), but directives on IHS (httpd.conf).
    Hi,
    The other server is a Tomcat server and not natted to a public IP. hence the redirection from our servers.

    I am trying to use mod_jk for Apache, But facing the below issue
    httpd: Syntax error on line 935 of /usr/IBM/HTTPServer/conf/httpd.conf: Cannot load /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so into server: \t0509-022 Cannot load module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so.\n\t0509-150 Dependent module mod_dir.so could not be loaded.\n\t0509-022 Cannot load module mod_dir.so.\n\t0509-026 System error: A file or directory in the path name does not exist.\n\t0509-022 Cannot load module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so.\n\t0509-150 Dependent module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so could not be loaded.
    $

    Not sure if IHS supports mod_jk , or my httpd.conf entries are wrong
    1. Load mod_jk module
    LoadModule jk_module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so
    1. Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
    #AddModule mod_jk.c
    1. Where to find workers.properties
    JkWorkersFile /usr/IBM/HTTPServer/properties/workers.properties
    1. Where to put jk shared memory:Chkthis
    #JkShmFile /var/log/httpd/mod_jk.shm
    1. Where to put jk logs
    JkLogFile /usr/IBM/HTTPServer/logs/mod_jk.log
    1. Set the jk log level debug/error/info
    JkLogLevel info
    1. Select the timestamp log format
    JkLogStampFormat "%a %b %d %H:%M:%S %Y "
    1. Send servlet for context /examples to worker named worker1
    JkMount /egi/servlet/* worker1
    1. Send JSPs for context /examples to worker named worker1
    JkMount /examples/*.jsp worker1

    Any Help ?
  • Sunit
    Sunit
    199 Posts

    Re: URL redirection

    ‏2012-02-21T14:20:33Z  
    Hi Sunit,
    After a lot of experiments , i am stll unable to re-direct/forward the request from my server(SERVER A) to the other server(SERVER B).

    Maybe i was unable to explain myself earlier , but my main requirement is that WAS using some plugin/servlet/configurationfile (anything) should forward the incoming HTTP request to another server(SERVER B). This server is not exposed to a public IP.

    The plugin/servlet/configurationfile should receive the response also and forward to browser.

    I tried doing this using servlets - requestdispatcher.forward , but in our case the the other application on SERVER B , is proprietary and cannot be hosted on our server.
    -please help me!
    If I understand this correctly, the request originates from a browser and to Server A. You want some mechanism on Server A to forward the request to Server B and then send the response back to browser.

    Server B is Tomcat but you have WAS components including HTTP server on Server A.

    If this is accurate then see : http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html

    • Sunit
  • Sunit
    Sunit
    199 Posts

    Re: URL redirection

    ‏2012-02-21T14:28:59Z  
    Hi,
    The other server is a Tomcat server and not natted to a public IP. hence the redirection from our servers.

    I am trying to use mod_jk for Apache, But facing the below issue
    httpd: Syntax error on line 935 of /usr/IBM/HTTPServer/conf/httpd.conf: Cannot load /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so into server: \t0509-022 Cannot load module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so.\n\t0509-150 Dependent module mod_dir.so could not be loaded.\n\t0509-022 Cannot load module mod_dir.so.\n\t0509-026 System error: A file or directory in the path name does not exist.\n\t0509-022 Cannot load module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so.\n\t0509-150 Dependent module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so could not be loaded.
    $

    Not sure if IHS supports mod_jk , or my httpd.conf entries are wrong
    1. Load mod_jk module
    LoadModule jk_module /usr/IBM/HTTPServer/Plugins/bin/mod_jk.so
    1. Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
    #AddModule mod_jk.c
    1. Where to find workers.properties
    JkWorkersFile /usr/IBM/HTTPServer/properties/workers.properties
    1. Where to put jk shared memory:Chkthis
    #JkShmFile /var/log/httpd/mod_jk.shm
    1. Where to put jk logs
    JkLogFile /usr/IBM/HTTPServer/logs/mod_jk.log
    1. Set the jk log level debug/error/info
    JkLogLevel info
    1. Select the timestamp log format
    JkLogStampFormat "%a %b %d %H:%M:%S %Y "
    1. Send servlet for context /examples to worker named worker1
    JkMount /egi/servlet/* worker1
    1. Send JSPs for context /examples to worker named worker1
    JkMount /examples/*.jsp worker1

    Any Help ?
    Make sure your mod_jk.so load module is in the correct subdirectory. Usually it will be called modules.

    You should then have something like

    LoadModule jk_module modules/mod_jk.so

    And then configure rest of it.
    http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

    • Sunit
  • Dhar_Abhay
    Dhar_Abhay
    12 Posts

    Re: URL redirection

    ‏2012-02-22T07:31:26Z  
    • Sunit
    • ‏2012-02-21T14:28:59Z
    Make sure your mod_jk.so load module is in the correct subdirectory. Usually it will be called modules.

    You should then have something like

    LoadModule jk_module modules/mod_jk.so

    And then configure rest of it.
    http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

    • Sunit
    Hi Sunit,
    I have tried to place the mod_jk.so in /modules , but I am getting the same exception after saving httpd.conf and stoping httpd.

    httpd: Syntax error on line 938 of /usr/IBM/HTTPServer/conf/httpd.conf: Cannot load /usr/IBM/HTTPServer/modules/libexec/mod_jk.so into server: \t0509-022 Cannot load module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so.\n\t0509-150 Dependent module mod_dir.so could not be loaded.\n\t0509-022 Cannot load module mod_dir.so.\n\t0509-026 System error: A file or directory in the path name does not exist.\n\t0509-022 Cannot load module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so.\n\t0509-150 Dependent module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so could not be loaded.
    • Also, I am unable to get the latest binaries for IHS from http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/aix/
    Could this be because jakarta has been retired , is there any archive site I could check ?
  • Sunit
    Sunit
    199 Posts

    Re: URL redirection

    ‏2012-02-22T14:16:48Z  
    Hi Sunit,
    I have tried to place the mod_jk.so in /modules , but I am getting the same exception after saving httpd.conf and stoping httpd.

    httpd: Syntax error on line 938 of /usr/IBM/HTTPServer/conf/httpd.conf: Cannot load /usr/IBM/HTTPServer/modules/libexec/mod_jk.so into server: \t0509-022 Cannot load module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so.\n\t0509-150 Dependent module mod_dir.so could not be loaded.\n\t0509-022 Cannot load module mod_dir.so.\n\t0509-026 System error: A file or directory in the path name does not exist.\n\t0509-022 Cannot load module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so.\n\t0509-150 Dependent module /usr/IBM/HTTPServer/modules/libexec/mod_jk.so could not be loaded.
    • Also, I am unable to get the latest binaries for IHS from http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/aix/
    Could this be because jakarta has been retired , is there any archive site I could check ?
    This is from the error message:
    /usr/IBM/HTTPServer/modules/libexec/mod_jk.so

    Why is it looking in modules/libexec directory for mod_dir.so and mod_jk.so? These modules should be in /usr/IBM/HTTPServer/modules

    Some more info for you to read:
    http://publib.boulder.ibm.com/wasce/V2.1.1/en/configuring-a-remote-ihs-with-wasce.html

    • Sunit
  • Dhar_Abhay
    Dhar_Abhay
    12 Posts

    Re: URL redirection

    ‏2012-02-22T14:44:46Z  
    • Sunit
    • ‏2012-02-22T14:16:48Z
    This is from the error message:
    /usr/IBM/HTTPServer/modules/libexec/mod_jk.so

    Why is it looking in modules/libexec directory for mod_dir.so and mod_jk.so? These modules should be in /usr/IBM/HTTPServer/modules

    Some more info for you to read:
    http://publib.boulder.ibm.com/wasce/V2.1.1/en/configuring-a-remote-ihs-with-wasce.html

    • Sunit
    I had given this path in httpd.conf "/usr/IBM/HTTPServer/modules/libexec/mod_jk.so" because i read somewhere that mod_jk.so , requires that folder structure
    But i have tried putting mod_jk.so in modules directory as well, and getting the same error.

    I tried building the sources, But getting below stack
    checking for echo... /usr/bin/echo
    checking for sed... /usr/bin/sed
    checking for cp... /usr/bin/cp
    checking for mkdir... /usr/bin/mkdir
    need to check for Perl first, apxs depends on it...
    checking for perl... /usr/bin/perl
    APRINCLUDEDIR is -I/usr/IBM/HTTPServer/include -I/usr/IBM/HTTPServer/include
    building connector for "apache-2.0"
    checking for gcc... xlc_r
    checking for C compiler default output file name... configure: error: C compiler cannot create executables
    See `config.log' for more details.
    I am not sure if this version of mod_jk.so is compatible with IHS6.0
  • Dhar_Abhay
    Dhar_Abhay
    12 Posts

    Re: URL redirection

    ‏2012-03-03T16:35:07Z  
    I had given this path in httpd.conf "/usr/IBM/HTTPServer/modules/libexec/mod_jk.so" because i read somewhere that mod_jk.so , requires that folder structure
    But i have tried putting mod_jk.so in modules directory as well, and getting the same error.

    I tried building the sources, But getting below stack
    checking for echo... /usr/bin/echo
    checking for sed... /usr/bin/sed
    checking for cp... /usr/bin/cp
    checking for mkdir... /usr/bin/mkdir
    need to check for Perl first, apxs depends on it...
    checking for perl... /usr/bin/perl
    APRINCLUDEDIR is -I/usr/IBM/HTTPServer/include -I/usr/IBM/HTTPServer/include
    building connector for "apache-2.0"
    checking for gcc... xlc_r
    checking for C compiler default output file name... configure: error: C compiler cannot create executables
    See `config.log' for more details.
    I am not sure if this version of mod_jk.so is compatible with IHS6.0
    My IHS version is 7.0 , any configuration or binary which could be causing the issue.
    I have placed the mod_jk.so in the correct path, I am not sure which configuration i have missed.

    -Abhay