I run a small SOHO network. I NAT/port forward on my router to get traffic to my handful of servers.

I setup an Ubuntu 10.04.4 server with Zimbra 7.1.4_GA_2555.FOSS. Let's call it host1.internal.local.

The server currently has two mail domains, call them domain1.com and domain2.com. Both offer webmail access at webmail.domain1.com and webmail.domain2.com.

I have a separate server with nginx. I want to configure nginx to reverse proxy to the Zimbra server, such that I can direct all HTTP/HTTPS to the nginx server and then distribute across other servers from nginx. I need to send webmail traffic via matched host address/headers to the Zimbra server.

The basic configuration of:

server {
listen 80;
server_name webmail.domain1.com;

access_log /var/log/nginx/access.log main buffer=32k;
error_log /var/log/nginx/error.log;

location / {
proxy_pass http://webmail.domain1.com;
proxy_set_header Host $http_host;

does not seem to work. (LAN DNS would resolve the http://webmail.domain1.com to the right server.) I get a 500 error. (The same config proxies regular www sites just fine.)

Has anyone ever done anything like this? If so, how?