最后刚刚完成 Ex change 项目正式上线工作,考虑到一些用户的特殊要求,打算将 OWA 发布到公网,考虑到安全因素,不采用端口映射方式,另外也因为一些其它原因,没有采用微软建议方式,采用 ISA 发布。(网上资料很多,已有很多成熟的方案,如无成本等方面原
最后刚刚完成Exchange项目正式上线工作,考虑到一些用户的特殊要求,打算将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 { # 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文件即可。让Proxy把资源反向代理到正确的服务器。
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查询,也可以,只是降低了相关安全性而已。
下载本文