Set up Dispatcher in AEM

In this tutorial i am going to take you through how to set up dispatcher in AEM. Setting up a dispatcher and configuring it, is generally a job of system administrator. But now a days companies are looking for developers who are multi tasking and can also take up the job of system admin along with development as and when required. So it makes it more important to learn how to set up dispatcher in aem for developers also.

After completing this tutorial you should be able to tell:-

What is a Dispatcher:-


Dispatcher is basically used to perform Caching, Load Balancing and filter incoming request from client to AEM publish instances. It also protects our AEM publish servers from attacks by restricting access from unknown sources using filters.

Install Apache Web server on Windows:

Download previous version binary msi file http://archive.apache.org/dist/httpd/binaries/win32/ .In this tutorials, I am going to use Apache web server 2.2 version as dispatcher is not supported for windows Apache web server 2.4 and above.

download apache webserver 2.2.25 msi file

Double click the msi file and click next and finish

install apche webserver aem

Note:- If you are getting error message that port already in use update the port number in httpd.conf file(C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf) and restart the server. If webserver is installed successfully then you will receive a screen saying “it works” else you will get a blank screen.

  • Go to your httpd.conf file C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf
  • Change default Define SRVROOT or ServerRoot  path to absolute path of your apache2.2 folder “C:\Program Files (x86)\Apache Software Foundation\Apache2.2” (Line – 38).
  • Update listen port Listen 8080 (Line – 47), it is optional if you don’t want to change you can keep default port as 80.
  • Update ServerName localhost:8080 (Line – 173), it is optional if you don’t want to change you can keep default port as 80.
  • Go to bin folder and open command prompt.
  • run httpd -k install
  • run httpd -k start

Note:- If you are getting error message on command prompt that port already in use, go to httpd.conf, it is dispatcher configuration file. open this file and change the Listen port.

Note:- If you are getting error vcruntime140.dll is missing, then you might not have installed it or try re-installing visual C++ studio. You can get Microsoft Visual C++ Redistributable from official Microsoft website. Click the download button

runtimedlll-error

Test successful installation of Apache:-


Goto localhost:8080. If it is successfully installed. you will get apache haus page. Else you will receive a blank screen.

test apache webserver installation

 

Installing Dispatcher on webserver for windows machine:-


It’s very simple to install and plug in dispatcher on any web server. You just need to follow below steps:-

  • Download dispatcher build
  • Modify Apache web server httpd.conf file
  • Modify dispatcher.any file
  • Restart Apache web server and you are done.

Download dispatcher build:-

Download the latest dispatcher build, but for window as we don’t have dispatcher build for windows. We are going to use Apache 2.2 as stated above.

  • Go to https://www.adobeaemcloud.com/content/companies/public/adobe/dispatcher/dispatcher.html
  • Download dispatcher-apache2.2-windows-x86-4.2.1.zip.
    download dispacher for windows
  • Unzip the downloaded dispatcher zip file. It will contain:-
    • disp_apache2.2.dll – This is my dispatcher module file, which we will plug in with web server.
    • dispatcher.any – It is our dispatcher configuration file.
    • author_dispatcher.any – Sample file for configuring our dispatcher.
    • httpd.conf.disp2.conf – sample file to configure apache webserver.
  • Now got to Apache installation directory C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf and open httpd.conf file.
  • Open you httpd.conf.disp2  also copy below setting from this file to httpd.conf file
    • Copy LoadModule dispatcher_module  modules/mod_dispatcher.so  at (line 234) and paste any where in httpd.conf file. I am going to paste it at (line 130) where my load modules are ending.
      Note:-This setting is used by apache webserver to load my dispatcher when next time Apache web server is started.
    • As my dispatcher module name is disp_apache2.2.dll. I will change modules/mod_dispatcher.so  in above line to modules/disp_apache2.2.dll.
    • Now copy the dispatcher level setting from httpd.conf.disp2.conf (Line 236 -284)  as shown below and paste it to httpd.conf file after ending of </IfModule> tag. I am pasting it at (line 146) where my if module is ending. This setting consist of:-
      • DispatcherConfig – location of the configuration file
      • DispatcherLog– location of the dispatcher log file
      • DispatcherPassError – to use your dispatcher for handling errors, if set to 1 then webserver will handle errors.
      • DispatcherKeepAliveTimeout – Time interval fo rwhich your request should be kept alive.

 

</strong></em>

<IfModule disp_apache2.c>

# location of the configuration file. eg: 'conf/dispatcher.any'
DispatcherConfig conf/dispatcher.any

# location of the dispatcher log file. eg: 'logs/dispatcher.log'
DispatcherLog logs/dispatcher.log

# log level for the dispatcher log, can be either specified
# as a string or an integer (in parentheses)
# error(0): Errors
# warn(1): Warnings
# info(2): Infos
# debug(3): Debug
# trace(4): Trace
DispatcherLogLevel warn

# if turned on, the dispatcher looks like a normal module
DispatcherNoServerHeader Off

# if turned on, request to / are not handled by the dispatcher
# use the mod_alias then for the correct mapping
DispatcherDeclineRoot Off

# if turned on, the dispatcher uses the URL already processed
# by handlers preceeding the dispatcher (i.e. mod_rewrite)
# instead of the original one passed to the web server.
DispatcherUseProcessedURL Off

# if turned to 1, the dispatcher does not spool an error
# response to the client (where the status code is greater
# or equal than 400), but passes the status code to
# Apache, which e.g. allows an ErrorDocument directive
# to process such a status code.
#
# Additionally, one can specify the status code ranges that should
# be left to web server to handle, e.g.
#
# DispatcherPassError 400-404,501
DispatcherPassError 0

#
# DispatcherKeepAliveTimeout specifies the number of seconds a
# connection to a backend should be kept alive. If not set or
# set to zero, connections are not kept alive.
#
#DispatcherKeepAliveTimeout 60

</IfModule>


Note:-
Do not paste this if module under any existing if module.

    • Now copy the dispatcher handler from httpd.conf.disp2.conf (line 370) to httpd.conf file (line 238) . This will override the default handle of web server and allow dispatcher to entertain all income requests. httpd.conf line number might vary in different version search for below code in httpd.conf file:-
      <Directory />
      AllowOverride none
      Require all denied
      </Directory>

      and add below code by creating one more directory tag:- 

<Directory />
 <IfModule disp_apache2.c>
 ModMimeUsePathInfo On
 # enable dispatcher for ALL request. if this is too restrictive,
 # move it to another location
 SetHandler dispatcher-handler
 </IfModule>

 Options FollowSymLinks
 AllowOverride None
</Directory>
  • Now copy this disp_apache2.2.dll  file from downloaded dispatcher and paste it under C:\Program Files (x86)\Apache Software Foundation\Apache2.2\modules.
  • Now copy dispatcher.any file from downloaded dispatcher and paste it under C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf directory.
  • Double click and open dispatcher.any file and let make few modification to make our dispatcher up and running.
    • Go to line 31 and update renders section to point our publish instance. Update the hostname if required currently it is pointing to localhost and port to 4503 (My publish instance port).
    • Go to line 77 and instead of denying all request lets allow all request for testing. For Publish instance you should deny all request and allow specific , For author instance you should allow all and deny specific.
    • Update cache Doc Root. It should exactly match my httpd.conf Documentroot path. Copy Document root path from httpd.conf file and paste it in dispatcher.any file at line 132.
    • Save all settings and Restart your Apache Web server.

Test Dispatcher Installation:-


To test weather dispatcher is configured properly or not.

Note:- If it is not loading make sure publish instance is up and check web server error.log and dispatcher.log for more info.

That’s it, You have successfully set up and configured dispatcher on windows server and plugged in it with AEM 6.2.

For configuring advanced settings in dispatcher. Visit my next tutorial How to Configure Dispatcher in AEM.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.