使用mod_proxy改进LAMP 安全
http://tech.ddvip.com 2007年03月04日 社区交流
使用mod_proxy改进LAMP 安全。
# Stuff every Apache configuration needs
LockFile /var/lock/apache/accept.www-data.lock
PidFile /var/run/apache.www-data.pid
ServerName necessaryevil.facade.server
DocumentRoot "/home/www-data"
# Essential modules
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
# Which user to run this Apache configuration as
User www-data
Group www-data
# These must be set else the host isn't passed correctly
UseCanonicalName Off
ProxyVia On
ProxyRequests Off
# This must also be set, though it's only an option in Apache2
ProxyPreserveHost On
# The IP/port combination to listen on
Listen 9.20.1.1:80
# Using name-based virtual hosting allows you to host multiple sites per IP/port combo
NameVirtualHost 9.20.1.1:80
# Configuration to forward requests for startup.tld
<VirtualHost 9.20.1.1:80>
ServerName www.startup.tld
ServerAlias startup.tld
ProxyPass / http://127.0.0.2:10000/
ProxyPassReverse / http://127.0.0.2:10000/
ProxyPassReverse / http://www.startup.tld:10000/
ProxyPassReverse / http://startup.tld:10000/
</VirtualHost>
# Configuration to forward requests for reckless.tld
<VirtualHost 9.20.1.1:80>
ServerName www.reckless.tld
ServerAlias reckless.tld
ProxyPass / http://127.0.0.2:10001/
ProxyPassReverse / http://127.0.0.2:10001/
ProxyPassReverse / http://www.reckless.tld:10001/
ProxyPassReverse / http://reckless.tld:10001/
</VirtualHost>一定要注意这里的 ProxyPreserveHost 指令。这个指令是 Apache 2 提供的,它解决了将正确的 HTTP 头转发给后端服务器的一些问题。因此,强烈建议使用 Apache 2 实例作为 facade 服务器。
运行示例配置
根用户应该运行每个配置。Apache 将取得配置文件中指定的特权,并将其用于所有与主机相关的进程。清单 5 说明运行示例的方法。
清单 5. 启动示例服务器
/usr/sbin/apache -f /etc/apache/startup.tld.conf
/usr/sbin/apache -f /etc/apache/nimrod.tld.conf
/usr/sbin/apache2 -f /etc/apache2/facade.tld.confmod_proxy 方法的限制
一定要注意,本文中描述的方法不适用于需要 SSL 连接的域。这是因为 SSL 协议不允许域的虚拟主机。由于这个限制,任何 SSL 主机必须以适当的方式执行,让每个 SSL 域使用它自己的 IP/端口组合。这个限制对所有 Apache 配置都存在,使用这个解决方案的 Apache 也不例外。仍然可以在它们的所有者的用户 ID 下运行 SSL 域。
结束语
在本文中,使用 Apache 的 mod_proxy 模块构建了一个环境,在这个环境中有一个门面服务器将请求转发给两个后端服务器。可以对一系列后端服务器采用同样的方法。这种方法使系统管理员能够降低潜在的安全风险,同时保持 PHP 等工具提供的灵活性。
来源:IBM DW中国 作者:Nick Maynard 责编:豆豆技术应用
正在加载评论...
- Linux/Unix 新闻
- Linux/Unix 入门
- Linux/Unix 命令
- Linux/Unix 安装
- Linux 嵌入式系统
- Linux/Unix 编程
- Linux/Unix 管理
- Linux/Unix 桌面
- Linux/Unix 内核
- Linux/Unix 软件
- Linux 系统安全
- SCO Unix
- NetBSD
- OpenBSD
- Redhat/Fedora Linux
- 手机
- Linux/Unix find 搜索命令
- Linux/Unix vi 命令
- Linux/Unix kde 桌面环境
- Linux/Unix GNOME 桌面环境
- Linux/Unix Make 命令
- Linux/Unix crontab 命令
- Linux/Unix ext3 文件系统
- Linux/Unix 文件系统详解
- Linux/Unix ADSL 拨号设置
- Linux/Unix GRUB 配置及应用
- Linux/Unix nfs配置
- Linux/Unix 硬件信息查看及管理
- Linux/Unix 优化
- Linux/Unix 交换分区Swap管理及应用
- Linux/Unix 用户管理
- Linux/Unix Ramdisk
- Linux/Unix 密码恢复管理
- Linux/Unix 文件删除恢复
- Linux/Unix fdisk分区
- Linux/Unix lvs负载均衡管理
- Linux/Unix root用户
- Linux/Unix 集群
- Linux/Unix 日志
- 更多Linux/Unix专题……