Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Thursday, October 9, 2014

Reverse Proxy configuration in Apache

A Reverse Proxy is a type of server that retrieves resources from other servers on behalf of the client. The resources are returned to the client as though they are originated from the server itself. Client feels that the resources are being provided by the server itself, and unaware of the servers that have provided the resources.Forward proxy acts as an intermediary for its clients and returns the resources accessible on the internet.Reverse proxy acts as an intermediary for the servers to return the resources provided by other servers.Reverse proxy is most widely used when you want your application accessible in the internet, without exposing the Application Servers, in other words, it is used when you want your intranet application to be accessible through internet.The proxied server may be a webserver itself, or it may be an application server using a different protocol, or an application server.


How to configure Reverse Proxy in Apache ?

  • Below Modules developed for Reverse proxy configuration in Apache
    • proxy_module               mod_proxy.so
    • proxy_http_module       mod_proxy_http.so  
  • Load the modules in httpd.conf file as below
    • LoadModule proxy_module       modules/mod_proxy.so
    • LoadModule proxy_http_module  modules/mod_proxy_http.so
  • Add the below configuration lines in httpd.conf file
             <Location /Reverse_Proxy/>
                   ProxyPass                http://backenserver.com/Reverse_Proxy/
                  ProxyPassReverse   http://backenserver.com/Reverse_Proxy/
            </Location>

Note: If Virtual hosts configured in Apache webserver place the above block of statements in Virtual host block.

<VirtualHost *:80>
          ServerName  myserver.com
    <Location /Reverse_Proxy/>
          ProxyPass                http://backenserver.com/Reverse_Proxy/
          ProxyPassReverse   http://backenserver.com/Reverse_Proxy/
     </Location>
</VirtualHost>

How Reverse Proxy Works ?

When request comes to Apache webserver it  checks for the context path in httpd.conf file and takes the  back end server information in Reverse proxy configuration block .Reverse Proxy module  sends the request to the back end (proxy server) and get the response from back end server and give to the client.

Is Context Path in Location tag and Context path of Back end server Should be same ?
No need to be same. We can change the context path in the Location tag as per our requirements.

Note: Back end server Context Path Should be valid one otherwise we wont get the results.

<VirtualHost *:80>
           ServerName  myserver.com
    <Location /Test_Reverse_Proxy/>
          ProxyPass                http://backenserver.com/Reverse_Proxy/
          ProxyPassReverse   http://backenserver.com/Reverse_Proxy/
     </Location>
</VirtualHost>
  • http://myserver.com/Test_Reverse_Proxy
  • http://myserver.com/Reverse_Proxy
 Both URL's gives the same results because both are accessing same back end servers

Note: Apache modules are Operating System's Specific so we should  load the Apache OS Specific Modules.

Friday, October 3, 2014

Weblogic integration with Apache webserver

weblogic_module Module developed to integrate the weblogic application server with Apache webserver. Module version varied according with Apache version.

  • For 2.0.x Apache  : mod_wl_20.so
  • For 2.2.x Apache  : mod_wl_22.so
Weblogic_module  plugin available at weblogic installation package or can be download from Apache download Mirrors.

{Installation Path}/wlserver_10.3.5/server/plugin/solaris/sparc/mod_wl_20.so
{Installation Path}/wlserver_10.3.5/server/plugin/solaris/sparc/mod_wl_22.so

{Installation Path}/wlserver_10.3.5/server/plugin/linux/x86_64/mod_wl_20.so
{Installation Path}/wlserver_10.3.5/server/plugin/linux/x86_64/mod_wl_22.so

Note: Plugin is operating system specific so we  should use the Apache webserver  operating system specific plugin.

Steps to integrate Weblogic application server with Apache
  • Load the weblogic_module as below in httpd.conf file.
            LoadModule weblogic_module /modules/mod_wl_20.so
  • Add the below configuration tags in httpd.conf file.
  <Location /weblogic_app >
SetHandler weblogic-handler
WLLogFile /apache/2.0.55/logs/wlproxy.log
WLProxySSL ON
WebLogicCluster weblogic-server1.com:7009,weblogic-server2.com:7009
 </Location>

Note: If Virtual hosts has configured , place the above configuration in virtual host tag 

# Ensure that Apache listens on port 80
Listen 8080

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:8080

<VirtualHost *:8080>
ServerName www.weblogic.com
  <Location /weblogic_app >
SetHandler weblogic-handler
WLLogFile /apache/2.0.55/logs/wlproxy.log
WLProxySSL ON
WebLogicCluster weblogic-server1.com:7009,weblogic-server2.com:7009
 </Location>
</VirtualHost>

  • Restart the Apache server to reflect the changes
Note: The above configuration is for weblogic clustered servers. If we have more managed servers in a weblogic cluster use the configuration as below 

WebLogicCluster weblogic-server1.com:7009,weblogic-server2.com:7009,weblogic-server3.com:7009,weblogic-server4.com:7009

<Location /weblogic_app >
SetHandler weblogic-handler
WLLogFile /apache/2.0.55/logs/wlproxy.log
WLProxySSL ON
WebLogicCluster weblogic-server1.com:7009,weblogic-                                                                         server2.com:7009,weblogic-server3.com:7009,weblogic-server4.com:7009
 </Location>

  • If we want to integrate  the standalone or single weblogic server instance use the below configuration.
  <Location /Single_weblogic_app>
SetHandler weblogic-handler
WebLogicHost weblogic-single_app.com
WebLogicPort 7009
 </Location>


Thursday, October 2, 2014

Websphere application server (WAS) integration with Apache Webserver

WAS plugins  developed to integrate the websphere application server with Apache server.WAS plugins vary according with Apache webserver version.

  • 2.0.x Apache version mod_was_ap20_http.so
  • 2.2.x Apache version mod_was_ap22_http.so
Plugins available along with WAS installation software package or can be download from IBM download mirrors.

WAS plugins location in installation package

{Installation Package}/plugin/plg.webserverplugins.pak/repository/plugins.http/bin/mod_was_ap20_http.so
.{Installation Package}/plugin/plg.webserverplugins.pak/repository/plugins.http/bin/mod_was_ap22_http.so

Add the below configuration lines in  httpd.conf file to Integrate the Websphere Application server with Apache webserver

LoadModule was_ap20_module  modules/mod_was_ap20_http.so

WebSpherePluginConfig  modules/plugin-cfg.xml

Note: WAS plugin is operating system specific so we should place the same os specific file other wise we can get the below error.

Syntax error on line 56 of /apache/2.0.55/conf/httpd.conf:
Cannot load /apache/2.0.55/modules/mod_was_ap20_http.so into server: /apache/2.0.55/modules/mod_was_ap20_http.so: wrong ELF class: ELFCLASS32

Tuesday, September 30, 2014

Tomcat integration with Apache webserver

AJP (Apache JServ protocol) is a communications protocol developed by apache.org to facilitate integration of the Tomcat container with third party web servers.Web server specific AJP plugins have been developed for Apache, IIS and Netscape's iPlanet.mod_jk.so  module developed to integrate the Apache web server with Tomcat container.

Steps to integrate the Apache webserver with Tomcat Container

  • Load the module as below in httpd.conf file

                 LoadModule jk_module modules/mod_jk.so

  • Add the below entry in httpd.conf file

Note: If virtual hosts configured , place the below configuration in virtual host block

<IfModule mod_jk.c>
     
      JkWorkersFile /data/apache/http-2.0.0.3/conf/workers.properties
      JkLogFile /data/apache/http-2.0.0.3/logs/mod_jkLog.log
      JkShmFile /tmp/jk-runtime-status
      JkLogLevel info
      JkMount /singleapp* Server-s
      JkMount /clusterapp* Server-c
   
</IfModule>

Create the worker.properties file as below 

workers.properties
-------------------------------------
worker.list=Server-s,Server-c  (Worker Nodes)
worker.Server-c.type=lb
worker.Server-c.balanced_workers=Server-c1, Server-c2 (Clustered Nodes)
worker.Server-c.sticky_session=1

worker.Server-c1.port=8009
worker.Server-c1.host=Server-c1.com
worker.Server-c1.type=ajp13
worker.Server-c1.lbfactor=1
worker.Server-c1.ping_mode=A

worker.Server-c2.port=8009
worker.Server-c2.host= Server-c2.com
worker.Server-c2.type=ajp13
worker.Server-c2.lbfactor=1
worker.Server-c2.ping_mode=A

worker.Server-s.port=8009
worker.Server-s.host=Server-s.com
worker.Server-s.type=ajp13
worker.Server-s.lbfactor=1
worker.Server-s.ping_mode=A

Server-s is single node and pointing to single tomcat server
Server-c is Cluster node and pointing to two clustered tomcat servers

Sunday, August 24, 2014

Apache web server plugins


  •  mod_wl_20.so : To integrate with weblogic application server
  • mod_jk.so : To integrate with Tomcat server
  • libmod_sm20.so: Site minder