Provide HTTP(s) Integration with Apache: Difference between revisions

mNo edit summary
Line 12: Line 12:
* You want to provide both http (insecure) and https (secure) access to clients through the webmail interface.
* You want to provide both http (insecure) and https (secure) access to clients through the webmail interface.


* On 'server.com' you want to provide webmail access when users visit 'http://webmail.server.com' and secure acces when they visit 'https://webmail.server.com'.
* On 'server.com' you want to provide webmail access when users visit 'http://webmail.server.com' and secure access when they visit 'https://webmail.server.com'.


* The Apache server listens on default ports 80 and 443, the Zimbra server listens on port 81 and uses the insecure login authentication method (zmtlsctl http).
* The Apache server listens on default ports 80 and 443, the Zimbra server listens on port 81 and uses the insecure login authentication method (zmtlsctl http).
Line 19: Line 19:


* [http://www.europe.redhat.com/ RedHat] or [http://www.centos.org/ CentOS] Linux installation
* [http://www.europe.redhat.com/ RedHat] or [http://www.centos.org/ CentOS] Linux installation
* Installed [http://httpd.apache.org/ Apache] webserver
* Installed [http://httpd.apache.org/ Apache] web-server
* Familiarity with [http://httpd.apache.org/docs/1.3/vhosts/examples.html Apache VirtualHost] configuration files
* Familiarity with [http://httpd.apache.org/docs/1.3/vhosts/examples.html Apache Virtualhost] configuration files
* Working [http://wiki.zimbra.com/index.php?title=Installation_Articles Zimbra] installation
* Working [http://wiki.zimbra.com/index.php?title=Installation_Articles Zimbra] installation


Line 29: Line 29:
===Advice===
===Advice===


The article has been written by community members, Zimbra administrators and experienced coders - the proof reading may not be perfect and aims to provide ideas and an exampe of a successful working practice.
The article has been written by community members, Zimbra administrators and experienced coders - the proof-reading may not be perfect and aims to provide ideas and an example of a successful working practice.


Please feel free to use the [http://www.zimbra.com/forums/ Zimbra Forums] to request more specific help, follow the article closely and do not rush - it will only take longer !!
Please feel free to use the [http://www.zimbra.com/forums/ Zimbra Forums] to request more specific help, follow the article closely and do not rush - it will only take longer !


[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
Line 121: Line 121:
The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes.
The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes.


Always usefull - we tell Apache to keep a log of any errors in the usual /var/log/httpd/ directory using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).
Always useful - we tell Apache to keep a log of any errors in the usual /var/log/httpd/ directory using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).


[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
Line 159: Line 159:
The new virtual host, again, has a server alias of webmail.* - meaning any virtual domain on your server's IP addresses beginning with webmail. will be handled here - as before but ensuring all https requests are acknowledged.
The new virtual host, again, has a server alias of webmail.* - meaning any virtual domain on your server's IP addresses beginning with webmail. will be handled here - as before but ensuring all https requests are acknowledged.


The proxypass line silently redirects all traffic to the zimbra port without the user knowing what is going on behind the scenes, as before but this time wrapping the insecure backend within the https frontend to the client's browser.
The proxypass line silently redirects all traffic to the zimbra port without the user knowing what is going on behind the scenes, as before but this time wrapping the insecure back-end within the https front-end to the client's browser.


The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes, again wrapping the insecure backend responses ready for the secure server to client transfer.
The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes, again wrapping the insecure back-end responses ready for the secure server to client transfer.


Always usefull - we tell Apache to keep a log of any SSL errors in the usual /var/log/httpd/ directory, using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).
Always useful - we tell Apache to keep a log of any SSL errors in the usual /var/log/httpd/ directory, using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).


[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
[[#Setting up HTTP and HTTPS support through Apache VirtualHosts|Top]]
Line 177: Line 177:
======Apache config breakdown======
======Apache config breakdown======


Using the 'sudo' command to elevate our privileges, we run the httpd binary and the -t switch to test all configuraiton files for syntax errors.
Using the 'sudo' command to elevate our privileges, we run the httpd binary and the -t switch to test all configuration files for syntax errors.


Hopefully, the response should be:
Hopefully, the response should be:
Line 197: Line 197:
</code>
</code>


* Open your broswer and test your insecure login page
* Open your browser and test your insecure login page


http://webmail.server.com
http://webmail.server.com

Revision as of 03:24, 18 February 2008

Setting up HTTP and HTTPS support through Apache VirtualHosts

Scenario

Single production server, with public IP address running apache web server hosting multiple virtual domains, and Zimbra Groupware server to providing email and webmail access to users in multiple virtual domains.

The example domain used in this article is 'server.com' - replace with your own domain and is aimed at Redhat/CentOS based machines - the syntax of most commands will no doubt succeed on alternative Linux distributions but the file structuring may differ slightly.

Aims

  • You want to provide both http (insecure) and https (secure) access to clients through the webmail interface.
  • The Apache server listens on default ports 80 and 443, the Zimbra server listens on port 81 and uses the insecure login authentication method (zmtlsctl http).

System Requirements

Time To Implement

Outside of meeting the system requirements, and reading this article through - the actual coding will take between 5-15 minutes depending on how familiar you are with the Linux command-line and the Zimbra server.

Advice

The article has been written by community members, Zimbra administrators and experienced coders - the proof-reading may not be perfect and aims to provide ideas and an example of a successful working practice.

Please feel free to use the Zimbra Forums to request more specific help, follow the article closely and do not rush - it will only take longer !

Top

Laying the foundations

Plan of Action

All following commands are issued whilst logged in with the 'zimbra' user.

sudo su - zimbra

Top

Step 1

  • Ensure Zimbra is running on port 81

Using the syntax : zmprov ms <your-server> zimbraMailPort <your-port-number>

zmprov ms server.com zimbraMailPort 81

Step 1 Breakdown

We logged in as the 'zimbra' user, then using the zmprov command to manipulate server name pair values, tell Zimbra to use the mail port number 81.

n.b. a more detailed thread here

Top

Step 2

  • Tell Zimbra to use the http authentication method - this does not redirect logins to SSL basically.

zmtlsctl http
zmcontrol stop;zmcontrol start

Step 2 Breakdown

We issued the 'zmtlsctl' command and passed the http value (other options include https,both,mixed,redirect but they do not apply to this article)

The Zimbra server was then restarted using the 'zmcontrol' command.

Top

Step 3 - requires root access

  • Create a new apache configuration file to listen for webmail requests on port 80 within /etc/httpd/conf.d/zimbra.conf.

sudo su - 
nano /etc/httpd/conf.d/zimbra.conf

Once within your text editor ensure it looks like this:

<VirtualHost *:80> 
     ServerAlias webmail.*
     ProxyPass / http://server.com:81/
     ProxyPassReverse / http://server.com:81/
     ErrorLog /var/log/httpd/zimbra-error.log
</VirtualHost>

Step 3 Breakdown

We logged in as root using the 'sudo su - ' command, allowing us write access to the Apache configuration directory - located at /etc/httpd/conf.d/.

Then created a new virtual host that listens on port 80 on all network interfaces.

The new virtual host has a server alias of webmail.* - meaning any virtual domain on your server's IP addresses beginning with webmail. will be handled here.

The proxypass line silently redirects all traffic to the zimbra port without the user knowing what is going on behind the scenes.

The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes.

Always useful - we tell Apache to keep a log of any errors in the usual /var/log/httpd/ directory using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).

Top

Step 4 - requires root access

  • Create a new apache configuration file to listen for webmail requests on port 443 within /etc/httpd/conf.d/zimbra.conf

sudo su - 
nano /etc/httpd/conf.d/zimbra.conf

Add the following underneath our previous entry:

<VirtualHost *:443> 
        ServerAlias webmail.*
        SSLProxyEngine ON
        SSLEngine On
        SSLCertificateFile /opt/zimbra/ssl/ssl/server/server.crt
        SSLCertificateKeyFile /opt/zimbra/ssl/ssl/server/server.key
        ProxyPass / http://server.com:81/
        ProxyPassReverse / http://server.com:81/
        ErrorLog /var/log/httpd/zimbra_ssl-error.log
</VirtualHost>

Step 4 Breakdown

We logged in as root using the 'sudo su - ' command, allowing us write access to the Apache configuration directory - located at /etc/httpd/conf.d/.

Then we created a new virtual host that listens for https requests on port 443 on all network interfaces.

The new virtual host, again, has a server alias of webmail.* - meaning any virtual domain on your server's IP addresses beginning with webmail. will be handled here - as before but ensuring all https requests are acknowledged.

The proxypass line silently redirects all traffic to the zimbra port without the user knowing what is going on behind the scenes, as before but this time wrapping the insecure back-end within the https front-end to the client's browser.

The proxypassreverse line, simply listens for traffic coming back from the redirect - again without the end user knowing what is going on behind the scenes, again wrapping the insecure back-end responses ready for the secure server to client transfer.

Always useful - we tell Apache to keep a log of any SSL errors in the usual /var/log/httpd/ directory, using the ErrorLog line- in case we experience problems we can use the log to troubleshoot. (If all runs smoothly just a # to the beginning of this line to turn the error logging off).

Top

Apache Config check

  • Test the configuration file to ensure we have no syntax errors before restarting the server

sudo httpd -t

Apache config breakdown

Using the 'sudo' command to elevate our privileges, we run the httpd binary and the -t switch to test all configuration files for syntax errors.

Hopefully, the response should be:

Syntax OK

If not read the error carefully, check and re-check your zimbra.conf file and utilise your resources - i.e. Google, the Zimbra forums etc.

Top

Restart and test your login

  • Restart Apache

sudo /etc/init.d/httpd restart

  • Open your browser and test your insecure login page

http://webmail.server.com

  • Open a new tab and test your secure login page

https://webmail.server.com

Top

Created by Costa-101

External Links

Jump to: navigation, search