Difference between revisions of "Third-party software integration: Apache"

From OpenKM Documentation
Jump to: navigation, search
Line 177: Line 177:
 
     CustomLog logs/dms.test.com-access_log common
 
     CustomLog logs/dms.test.com-access_log common
 
  </VirtualHost>
 
  </VirtualHost>
 +
 +
{{Warning|If you have installed IIS you should change apache port Listen from 80 to other in httpd.conf}}
  
 
== More info ==
 
== More info ==

Revision as of 15:13, 26 March 2012

Expose OpenKM directly from JBoss can be dangerous if you need the application to be accessed from Internet (for example https://issues.jboss.org/browse/JBAS-3861). As result you can be infected by PerlBot. Also this 8080 may be closed by a firewall. For these reasons, is a good idea expose your OpenKM installation through the standard web port 80. In the following steps we explain how to configure Apache to handle these request and forward to JBoss application server using the AJP13 protocol.

From the Apache documentation: The AJP13 protocol is packet-oriented. A binary format was presumably chosen over the more readable plain text for reasons of performance. The web server communicates with the servlet container over TCP connections. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles.


Nota idea.png You can see how to configure Apache with SSL at Apache SSL and more article.

Debian / Ubuntu

The first thing in to install the required Apache software. From Debian / Ubuntu you can install Apache with a single command:

$ sudo aptitude install apache2

Edit the file called /etc/apache2/apache2.conf and configure a ServerName to prevent warnings in the Apache startup process:

ServerRoot "/etc/apache2"
ServerName "your-domain.com"

Enable the proxy module, needed to forward petitions to JBoss:

$ sudo a2enmod proxy_ajp

Now create the configuration file /etc/apache2/sites-available/openkm.conf with this content:

<VirtualHost *>
    ServerName openkm.your-domain.com
    RedirectMatch ^/$ /OpenKM
    <Location /OpenKM>
        ProxyPass ajp://127.0.0.1:8009/OpenKM
        ProxyPassReverse http://openkm.your-domain.com/OpenKM
    </Location>
    ErrorLog /var/log/apache2/your-domain.com-error.log
    CustomLog /var/log/apache2/your-domain.com-access.log combined
</VirtualHost>

The VirtualHost ServerName must be other than ServerName in the main Apache configuration. Enable this site configuration:

$ sudo a2ensite openkm.conf

Nota advertencia.png If after restart Apache you see a warning like:
[warn] NameVirtualHost *:80 has no VirtualHosts
you have to change the virtual host definition from <VirtualHost *> to <VirtualHost *:80>


Nota clasica.png If you see an error like:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

you need to enable this Apache module:

$ sudo a2enmod rewrite
$ sudo a2enmod proxy_http
$ sudo a2enmod headers

You have to enable explicitly the proxy access editing the Apache configuration file /etc/apache2/mods-available/proxy.conf:

<IfModule mod_proxy.c>
  #turning ProxyRequests on and allowing proxying from all may allow
  #spammers to use your proxy to send email.

  ProxyRequests Off

  <Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
    Deny from all
    #Allow from .example.com
  </Proxy>

  # Enable/disable the handling of HTTP/1.1 "Via:" headers.
  # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
  # Set to one of: Off | On | Full | Block

  ProxyVia On
</IfModule>

Finally restart Apache:

$ sudo /etc/init.d/apache2 restart

Now you can access your OpenKM installation from http://openkm.your-domain.com/. Another advantage of using Apache is that you can log OpenKM access and generate web statistics.

Red Hat / CentOS

Here you can use the yum application manager to install Apache:

$ sudo yum install httpd

Now create the file /etc/httpd/conf.d/openkm.conf with this content:

<VirtualHost *:80>
    ServerName openkm.your-domain.com
    RedirectMatch ^/$ /OpenKM
    <Location /OpenKM>
        ProxyPass ajp://127.0.0.1:8009/OpenKM
        ProxyPassReverse http://openkm.your-domain.com/OpenKM
    </Location>
    ErrorLog /var/log/apache2/your-domain.com-error.log
    CustomLog /var/log/apache2/your-domain.com-access.log combined
</VirtualHost>

After that, restart Apache to make effective this configuration.

$ sudo /etc/init.d/httpd restart

Mac OS X

Edit the file called /etc/apache2/apache2.conf and configure a ServerName, enable proxy modules and mod_proxy:

ServerRoot "/usr"
ServerName "your-domain.com"
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_ajp_module libexec/apache2/mod_proxy_ajp.so
<IfModule mod_proxy.c>
       ProxyRequests Off
       <Proxy "*">
               AddDefaultCharset off
               Allow from all
               Deny from all
               Order Deny,Allow
       </Proxy>
       ProxyVia On
</IfModule>

Now create the configuration file /etc/apache2/sites/openkm.conf with this content:

<VirtualHost *:80>
   ServerName openkm.your-domain.com
   RedirectMatch ^/$ /OpenKM
   <Location /OpenKM>
       ProxyPass ajp://127.0.0.1:8009/OpenKM
       ProxyPassReverse http://openkm.your-domain.com/OpenKM
   </Location>
   ErrorLog /var/log/apache2/your-domain.com-error.log
   CustomLog /var/log/apache2/your-domain.com-access.log combined
</VirtualHost>

Finally restart apache

Windows

Install de apache webserver from http://httpd.apache.org/download.cgi ( windows binary no mod_ssl )

Edit the C:\Archivos de programa\Apache Software Foundation\Apache2.2\conf\httpd.conf

# Enable proxy modules
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#Add in bottom 
NameVirtualHost *:80
<VirtualHost *:80>
   ServerName openkm.your-domain.com
   RedirectMatch ^/$ /OpenKM
   
   ProxyRequests Off
   ProxyVia On
   
   <Proxy *>
   	AddDefaultCharset off
   	Order deny,allow
   	Allow from all
   	Deny from All
   </Proxy>
   
   <Location /OpenKM>
       ProxyPass ajp://127.0.0.1:8009/OpenKM
       ProxyPassReverse http://openkm.your-domain.com/OpenKM
   </Location>
   
   ErrorLog logs/dms.test.com-error_log
   CustomLog logs/dms.test.com-access_log common
</VirtualHost>

Nota advertencia.png If you have installed IIS you should change apache port Listen from 80 to other in httpd.conf

More info

For more info, visit: