Set apache2 to proxy Zimbra

In some configurations it’s desirable to share apache2 and Zimbra on the same host. This would mean that either one of the two services shuold run on non-standard port, that is 80 and 443. If this is not an issue,

  • change the ports apache2 is listening to in /etc/apache2/ports.conf
  • change the portz zimbra is listening to using zmprov (zmprov gs zimbraserver zimbraMailPort 81)

But thanks to apache2‘s mod_proxy, you can have both services on the standard web ports.

These commands work on Debian/Ubuntu servers.

At first, enable apache2’s modules:

a2enmod proxy<br />
a2enmod proxy_html<br />
a2enmod proxy_http

Make sure the use of mod_proxy is allowed, by changing /etc/apache2/mods_available/proxy.conf

                Allow from all

In this case I want to proxy SSL, so before starting you will need to move Zimbra HTTPS away from port 443 (I moved to 444). Copy your Zimbra certificate files to a directory accessible by apache. I choose /etc/apache2/ssl.

To allow automatic redirect from / to /zimbra, as in your normal Zimbra install, add the following line to your main <Directory> stanza:

RedirectMatch ^/$ /zimbra/

Then, edit you apache2 config file and add:

SSLProxyEngine on<br />
SSLCertificateFile /etc/apache2/ssl/host.crt<br />
SSLCertificateKeyFile /etc/apache2/ssl/host.key<br />
SSLCACertificateFile /etc/apache2/ssl/ca_bundle.crt<br />
ProxyRequests On<br />
ProxyPreserveHost On<br />
ProxyVia full<br />
&lt;Location &quot;/service&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/service<br />
  ProxyPassReverse https://your_zimbra_ip:444/service<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /service /service<br />
&lt;/Location&gt;</p>
<p>&lt;Location &quot;/zimbra&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/zimbra<br />
  ProxyPassReverse https://your_zimbra_ip:444/zimbra<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /zimbra /zimbra<br />
&lt;/Location&gt;</p>
<p>&lt;Location &quot;/home&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/home<br />
  ProxyPassReverse https://your_zimbra_ip:444/home<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /home /home<br />
&lt;/Location&gt;</p>
<p># CalDAV<br />
&lt;Location &quot;/principals&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/principals<br />
  ProxyPassReverse https://your_zimbra_ip:444/principals<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /principals /principals<br />
&lt;/Location&gt;<br />
# DAV<br />
&lt;Location &quot;/dav&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/dav<br />
  ProxyPassReverse https://your_zimbra_ip:444/dav<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /dav /dav<br />
&lt;/Location&gt;<br />
#Printing and HTML interface<br />
&lt;Location &quot;/h&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/h<br />
  ProxyPassReverse https://your_zimbra_ip:444/h<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /h /h<br />
&lt;/Location&gt;</p>
<p># img for mobile interface<br />
&lt;Location &quot;/img&quot;&gt;<br />
  ProxyPass https://your_zimbra_ip:444/img<br />
  ProxyPassReverse https://your_zimbra_ip:444/img<br />
  ProxyPassReverse /<br />
  ProxyHTMLExtended      On<br />
  ProxyHTMLURLMap /img /img<br />
&lt;/Location&gt;<br />

Restart your apache2, and you should be done!
P.S. in case you wish to proxy https:

a2enmod ssl

Add the following to your /etc/apache2/sites-available/default-ssl

SSLProxyEngine on<br />
ProxyRequests On<br />
ProxyPreserveHost On<br />
ProxyVia full

and also add all the Location instances above.
UPDATE: added ssl certs on 2010.12.07.

3 pensieri su “Set apache2 to proxy Zimbra

  1. this certainly works but
    – login directly to zimbra has great performance.
    – login via this solution takes over 2 minutes to complete login and then working the web interface is horribly slow

  2. Hi,

    thx a lot. This very important step is not documented at Zimbra itselfs wiki.
    Works for Zimbra Open Source Version 8.8.9

    Thanks again!
    Otto

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Solve : *
8 + 7 =


Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.