1
0
Fork 0
blog.kempkens.io/content/posts/2014-02-17-exchange-reverse-proxy-using-nginx.md

45 lines
1.7 KiB
Markdown
Raw Normal View History

2014-03-23 19:40:19 +00:00
---
2021-08-28 19:50:49 +00:00
date: "2014-02-17T21:45:00Z"
description: Simple nginx configuration that allows you to proxy most of Microsoft Exchange.
tags:
- nginx
- exchange
- ops
- english
slug: exchange-reverse-proxy-using-nginx
2014-03-23 19:40:19 +00:00
title: Exchange Reverse Proxy Using nginx
---
As it turns out, setting up [nginx](http://nginx.org) as a reverse proxy for Microsoft Exchange is not as easy as [some](http://blog.friedlandreas.net/2013/07/reverseproxy-fur-eas-exchange-activesync-und-owa-outlookwebapp-mit-nginx/) [posts](http://www.administrator.de/wissen/ngnix-als-reverse-proxy-für-exchange-2010-192711.html) suggest.
The issue that for some calls (Autodiscovery, RPC, …) IIS asks for an `Authorization` header, which nginx can pass through by doing:
2021-08-28 19:50:49 +00:00
{{< highlight nginx >}}
2014-03-23 19:40:19 +00:00
proxy_pass_header Authorization;
2021-08-28 19:50:49 +00:00
{{< / highlight >}}
2014-03-23 19:40:19 +00:00
Only problem is: It doesn't work. Thankfully someone on StackOverflow already had a [solution](http://stackoverflow.com/a/19714696) for this:
2021-08-28 19:50:49 +00:00
{{< highlight nginx >}}
2014-03-23 19:40:19 +00:00
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_pass_header Date;
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
more_set_input_headers 'Authorization: $http_authorization';
proxy_set_header Accept-Encoding "";
more_set_headers -s 401 'WWW-Authenticate: Basic realm="your.mail.host"';
proxy_pass https://your.mail.host;
2021-08-28 19:50:49 +00:00
{{< / highlight >}}
2014-03-23 19:40:19 +00:00
You'll need the [HttpHeadersMore](http://wiki.nginx.org/HttpHeadersMoreModule) module for this to work. On Ubuntu 12.04 (using the [nginx/stable PPA](https://launchpad.net/~nginx/+archive/stable)) all you need to install is:
2021-08-28 19:50:49 +00:00
{{< highlight bash >}}
2014-03-23 19:40:19 +00:00
apt-get install nginx-extras
2021-08-28 19:50:49 +00:00
{{< / highlight >}}
2014-03-23 19:40:19 +00:00
And you're good to go!