在 DMZ 中将 Debian+Apache 配置为 OWA 反向代理
如果我们安装了 Exchange,并且想要在国外发布 OWA, 我们永远不应该直接打开我们的交易所的端口, 为此,DMZ 中有代理将向我们展示我们的 OWA. 在这种情况下,我们将使用 DEBIAN 和 APACHE 设置反向代理.
为此,我们从 DMZ 中安装了 Debian 的事实开始,其端口为 443 的 WAN 指向它并允许端口通过 443 从我们的服务器到 LAN 的 Exchange CAS.
Actualizamos nuestro servidor Debian
# apt-get update
# apt-get upgrade
Instalamos Apache
# apt-get install apache2 apache2-mpm-prefork
Activamos los modulos requeridos
# a2enmod proxy
# a2enmod proxy_http
# A2Enmod 接头
# a2enmod 重写
# a2enmod SSL
Reiniciamos Apache
# /etc/init.d/apache2 重启
Creamos los directorios para los certificados
# mkdir /etc/apache2/ssl.crt
# mkdir /etc/apache2/ssl.key
Exportamos el certificado de nuestro servidor Exchange a pfx. Botón derecho en el certificado y Exportar Certificado.
Le damos una ruta y un nombre, y le ponemos una contraseña y lo introducimos en nuestro linux con winscp por ejemplo.
Convertimos nuestro pfx a texto plano
# openssl pkcs12 -in correo.pfx -out correo.txt -nodes
Editamos el fichero correo.txt y veremos la RSA PRIVATE KEY 和 CERTIFICADO.
Los guardamos independientemente en 2 fichero correo.crt y correo.key
Movemos el certificado a su directorio
# mv correo.crt /etc/apache2/ssl.crt
Movemos la rsa key a su directorio
# mv correo.key mkdir /etc/apache2/ssl.key
Creamos la carpeta owa, aunque sera ficticia solo para la configuración pero no la usaremos.
# mkdir /var/www/owa
Creamos y editamos el fichero owa
# vim /etc/apache2/sites-available/owa
Introducimos la siguiente configuración para actuar como proxy:
NameVirtualHost *:80
<虚拟主机 *:80>
ServerName correo.tundra-it.com
ServerAdmin 在**@co****.c噢
DocumentRoot /var/www/owa
DirectoryIndex index.htm index.html
RedirectMatch ^/$ https://correo.tundra-it.com/owa
RedirectMatch ^/owa$ https://correo.tundra-it.com/owa
</虚拟主机>
NameVirtualHost *:443
<虚拟主机 *:443>
ServerName correo.tundra-it.com
ServerAdmin 在**@co****.c噢
DocumentRoot /var/www/owa
DirectoryIndex index.htm index.html
# Set up SSL to work with this host
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/apache2/ssl.crt/correo.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/correo.key
# Redirect to ‘/owa’ from ‘/’
RedirectMatch ^/$ /owa
RewriteEngine On
# Fix a problem when ‘%’ symbols are in the subject line of OWA email
# (the email subject is used in the web query)
RewriteMap percentsubject int:escape
RewriteCond $1 ^/owa/.*%.*$
RewriteRule (/owa/.*) ${percentsubject:$1} [P]
RequestHeader set Front-End-Https “On”
ProxyRequests Off
ProxyPreserveHost On
ProxyVia On
<Proxy *>
Order deny,allow
允许所有人
</代理>
#Reverse Proxy para OWA
ProxyPass /owa https://correo.tundra-it.com/owa
ProxyPassReverse /owa https://correo.tundra-it.com/owa
ProxyPass /exchweb https://correo.tundra-it.com/exchweb
ProxyPassReverse /exchweb https://correo.tundra-it.com/exchweb
ProxyPass /public https://correo.tundra-it.com/公共
ProxyPassReverse /public https://correo.tundra-it.com/公共
ProxyPass /iisadmpwd https://correo.tundra-it.com/iisadmpwd
ProxyPassReverse /iisadmpwd https://correo.tundra-it.com/iisadmpwd
ProxyPass /oma https://correo.tundra-it.com/oma
ProxyPassReverse /oma https://correo.tundra-it.com/oma
ProxyPass /Microsoft-Server-ActiveSync https://correo.tundra-it.com/Microsoft-Server-ActiveSync
ProxyPassReverse /Microsoft-Server-ActiveSync https://correo.tundra-it.com/Microsoft-Server-ActiveSync
ErrorLog /var/log/apache2/mailus-ssl-error_log
CustomLog /var/log/apache2/mailus-ssl-access_log common
</虚拟主机>
Activamos el sitio OWA
# a2ensite owa
Para no permitir el trafico DNS de la DMZ a los DNS de la LAN, introducimos el nombre del sitio local en el archivo hosts
# 回波 192.168.169.231 correo.tundra-it.com >> /etc/hosts
Reiniciamos el Apacahe
# /etc/init.d/apache2 重启
Entramos desde el exterior