最后刚刚完成 Ex change 项目正式上线工作,考虑到一些用户的特殊要求,打算将 OWA 发布到公网,考虑到安全因素,不采用端口映射方式,另外也因为一些其它原因,没有采用微软建议方式,采用 ISA 发布。(网上资料很多,已有很多成熟的方案,如无成本等方面原
最后刚刚完成 Ex change 项目正式上线工作,考虑到一些用户的特殊要求,打算将 OWA 发布到公网,考虑到安全因素,不采用端口映射方式,另外也因为一些其它原因,没有采用微软建议方式,采用 ISA 发布。(网上资料很多,已有很多成熟的方案,如无成本等方面原因,建议采用,主要是方案很成熟,省事。 ^_^ )
上面提了这么多要求,但是工作还得做,想了下,本质上就是让用户能在公网上能直接访问到 OWA ,但又不是直接访问到,所以想到这,就是加个中间人角色,让它帮忙把公网用户的要求传给内网服务器,说白了其实就是一 反向 代理 。
应用 反向 代理 的软件有很多, squid,nginx 等等大大有名,因为 nginx 现在很流行,且此软件占用资源少,等优点,就在自己喜欢的 gentoo 上并应用了。
下面给出此 代理 的部分网络架构图,大家看了就明白了是怎么回事了。
下面就正式开始 配置 工作
Exchange Server Name: msg114.sunwill.cn
OWA Internat Name: outlook.sunwill.cn
一、系统及 nginx 安装 ~ 略,这个很简单的,大家都知道的
二、在 Proxy 上生成 ssl 证书,这一步很重要,当然,如果已经有申请到证书,就直接拷过来用就行,没必要用自生成的证书。
# mkdir /etc/nginx/ssl.crt
# mkdir /etc/nginx/ssl.key
Make sure to:
- Copy your certificate file to: /etc/nginx/ssl.crt/
- Copy your certificate key file to: /etc/nginx/ssl.key/
证书生成过程,大家可以在网查到,网上也有很多教程,只要生成了证书,放到上面两个目录中就行, nginx 进行 代理 转发时用得到
三、就是 配置 OWA 的 反向 代理 了, 配置 文件如下所示
edward@jt-it001: ~ $ vim /etc/nginx/conf.d/owa .conf
server {listen 80;
server_name outlook.sunwill.cn;
# Redirect any HTTP request to HTTPS
rewrite ^(.*) https://outlook.sunwill.cn$1 permanent;
error_log /var/log/nginx/outlook.sunwill.cn-owa-error.log;
access_log /var/log/nginx/outlook.sunwill.cn-owa-access.log;
}
server {
listen 443;
server_name outlook.sunwill.cn;
auth_basic "sunwill";
auth_basic_user_file nginx_passwd;
# Redirect from "/" to "/owa" by default
rewrite ^/$ https://outlook.sunwill.cn/owa permanent;
# Enable SSL
ssl on;
ssl_certificate /etc/nginx/ssl.crt/outlook.sunwill.cn.crt;
ssl_certificate_key /etc/nginx/ssl.key/outlook.sunwill.cn.key;
ssl_session_timeout 5m;
# Set global proxy settings
proxy_read_timeout 360;
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;
location /owa { proxy_pass https://msg114.sunwill.cn/owa; }
location /exchange { proxy_pass https://msg114.sunwill.cn/exchange; }
location /exchweb { proxy_pass https://msg114.sunwill.cn/exchweb; }
location /public { proxy_pass https://msg114.sunwill.cn/public; }
location /Microsoft-Server-ActiveSync { proxy_pass https://msg114.sunwill.cn/Microsoft-Server-ActiveSync; }
error_log /var/log/nginx/outlook.sunwill.cn-owa-ssl-error.log;
access_log /var/log/nginx/outlook.sunwill.cn-owa-ssl-access.log;
}
最后一点,因为机器是放在 DMZ 中,所以有可能,其实也没必要让 Proxy 访问内网的 DNS 服务器,直接 配置 系统的 /etc/hosts 文件即可。让 Pro xy 把资源 反向 代理 到正确的服务器。
echo "192.168.103.200 msg114.sunwill.cn msg114" >> /etc/hosts
最后一些说明,
1. 公网域名 outlook.sunwill.cn 指向到 Proxy 的公网地址
2. 安全方面的一些考量,老生常谈了,服务器开启防火墙,只对外开户指定端口,服务器只运行需要的服务
3. 自建证书是因为 nginx 有启用 ssl, 所以需要,可以直接用 linux 上自建的证书,此证书不一定要与 exchange 服务器上的证书一样,当然如果有申请正式的证书,肯定是用这个了
4.host 记录一定要有,当然你愿意在 DMZ 区的防火墙上开户至内网的 DNS 查询,也可以,只是降低了相关安全性而已。
查看更多关于配置Nginx反向代理Exchange2007上的OWA的详细内容...