这么一个需求:同一台服务器上有两个应用,如
http://hostA:8080/services和http://hostA:8080/admin
外部访问时,需要从不同的域名访问,如
http://services.host.com和http://admin.host.com
一开始给他们这么一个比较简单的解决方案:
分别把services和admin两个应用,部署到不同的两个端口上,如
services -> http://hostA:8081/
admin -> http://hostA:8082/
接着在防火墙配两个公网IP,然后dns上把services.host.com和admin.host.com配置到这两个IP上。
当请求到达防火墙时,防火墙根据所访问的ip转发到hostA的对应端口上。
前 方用的防火墙是我们公司的Audemon 100,和公司的Audemon系统组的交流后得知,目前的防火墙版本不支持同时配置两个ip,要到六月底才能出版本支持。!@…%#%…%¥,晕倒,好 像这是很基本的功能来的吧,居然还不支持。没办法,此路不通。由于防火墙是不管域名的(因为域名资料是通过应用层传输的),那更别指望防火墙根据域名转发 了。
因此,我们只好提供了软件级的解决方案,让前方在Tomcat前加一个Apache 2.2,通过Apache的Virtual Host + AJP实现转发。
Apache的部分配置如下:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName host1.com
ProxyPass / ajp://host1.com:8009/
ProxyPassReverse / ajp://host1.com:8009/
</VirtualHost>
<VirtualHost *:80>
ServerName host2.com
ProxyPass / ajp://host2.com:8019/
ProxyPassReverse / ajp://host2.com:8019/
</VirtualHost>
Tomcat也需要配置AJP Connector,如host1.com的配置
<Connector port=”8009″ enableLookups=”false” redirectPort=”8443″ protocol=”AJP/1.3″ />
这个方案相对于防火墙的硬件方案,性能上要差一些,但还是不错的。
另 外还有一种方案是通过iptables的domain module来实现,但这个domain module好像是国内的某个高手写的,只更新到v0.02版本,并没有提交到iptables的标准里。虽然可以用而且性能比Apache的方案要高一 些,但是风险较大,而且配置麻烦(既要编译内核,又要配置iptables的rules),所以没有用这种方式。
本文来源于 冰山上的播客 http://xinsync.xju.edu.cn , 原文地址:http://xinsync.xju.edu.cn/index.php/archives/115
<Directory "/var/www/www">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/phorum">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# 针对三部主机的 DocumentRoot 进行定!
<VirtualHost *:80>
ServerName linux.vbird.tsai
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
ServerName www.vbird.tsai
DocumentRoot /var/www/www
CustomLog /var/log/httpd/www.access_log combined
# 不同的主页可以指定不同的登录档资讯,这样比较好 debug 与分析啦!
</VirtualHost>
<VirtualHost *:80>
ServerName phorum.vbird.tsai
DocumentRoot /var/www/phorum
</VirtualHost>
<VirtualHost *>
ServerAdmin xxx@xxx.org
ServerName xxxxx
ProxyRequests Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
# reverse proxy setting
ProxyPass / http://192.168.100.8:8180/
ProxyPassReverse / http://192.168.100.8:8180/
# cache dir root
CacheRoot "/var/www/proxy"
# max cache storage
CacheSize 50000000
# hour: every 4 hour
CacheGcInterval 4
# max page expire time: hour
CacheMaxExpire 240
# Expire time = (now - last_modified) * CacheLastModifiedFactor
CacheLastModifiedFactor 0.1
# defalt expire tag: hour
CacheDefaultExpire 1
# force complete after precent of content retrived: 60-90%
CacheForceCompletion 80
ErrorLog /var/log/apache2/error-westdc.geodata.cn.log
CustomLog /var/log/apache2/access-westdc.geodata.cn.log combined
ServerSignature On
</VirtualHost>
分享到:
相关推荐
win10系统配置虚拟主机 1.用记事本或Sublime Text打开httpd.conf ...<VirtualHost> ServerAdmin webmaster@youremail.com DocumentRoot E:/your_web_root ServerName your.web.com ErrorLog logs/your_web_
而在一个繁忙的网站上这一连接数量也许不能满足需要,特别是本文介绍的通过防火墙上的Apache反向代理允许外部用户访问多个内部Web服务器的情况,可以采用更改src/include/httpd.h文件的方法,具体步骤如下。...
<VirtualHost> ServerName auciou.com ServerAlias *.auciou.com DocumentRoot F:/site/auciou </VirtualHost> 重启Apache,就可以在本地同时使用auciou.com和xxx.auciou.com在本地访问,xxx为任意的二级域名,实现...
另外,Listen, NameVirtualHost和VirtualHost 指令支持IPv6的数字地址串(比如:“Listen [fe80::1]:8080”)。 过滤 Apache的模块现在可以写成过滤器的形式, 当内容流经它到服务器或从服务器到达的时候进行处理。 ...
另外,Listen, NameVirtualHost和VirtualHost 指令支持IPv6的数字地址串(比如:“Listen [fe80::1]:8080”)。 过滤 Apache的模块现在可以写成过滤器的形式, 当内容流经它到服务器或从服务器到达的时候进行处理...
方法一: 首先打开apache中conf下...<VirtualHost>//你的虚拟主机所使用的端口号 ServerAdmin webmaster@dummy-host2.localhost //虚拟主机的管理员账号 DocumentRoot “D:/wamp/www/phpwind” //所需配置的网站的文件路
只要像下面这样使用 VirtualHost 你可以实现: NameVirtualHost * <VirtualHost> ServerName www.example.com # ... SetEnv DJANGO_SETTINGS_MODULE mysite.settings </VirtualHost> <VirtualHost> ServerName ...
<VirtualHost *:80> ServerAdmin rosi@126.com DocumentRoot "D:/toots/Apache/docs/dummy-host3.localhost"//你的安装目录 ServerName localhost//服务名(域名) ServerAlias localhost//服务别名 ProxyPass ...
默认情况下,linux上apache使用的...8000Listen 8000(2)配置虚拟目录#cd /etc/apache2/sites-available#cp default default-me#vim default-me文件内容如下:复制代码 代码如下:<VirtualHost> ServerAdmin webmaster@l
包括 Apache VirtualHost 和 index.html 页面,以及嵌入的 CSS 样式以简化部署。反向代理一个简单的 apache2 反向代理。NIF验证器用于验证西班牙标识号 (NIF) 的 Java 类。Nodejs 网页抓取从获取新闻的 nodejs 示例...
在php.ini文件中使用如下 safe_mode = On (使用安全模式) safe_mode = Off (关闭安全模式) 在apache的httpd.conf中VirtualHost的相应设置方法 php_admin_flag safe_mode On (使用安全模式) ...或者: ...
本文实例讲述了PHP+Apache实现二级域名之间共享cookie的方法。分享给大家供大家参考,具体如下: 简介 ... 也就是说二级域名(或者三级域名)之间可以通过这种方式共享cookie。...VirtualHost 127.0.0.1:80
图像主机node.js 图像主机演示(有时):imagehost.colordeaf.net用法请求:发布图像数据响应:json 详细信息/重定向npm 笔记npm install -g 永远(全局安装forever喜欢 /usr/local/bin/forever...VirtualHost 74.207.
坑网 pitweb是使用python编写的git仓库的Web前端。 创建pitweb是因为我找不到适合在python托管上部署的任何Web...< VirtualHost> ServerName pitweb.host.com DocumentRoot " /path/to/directory " < Directory>
程序可以采用 JAVA 开发,但是因为它的虚拟机 (Virtual Machine) Dalvik ,是将 JAVA 的 bytecode 转成 自 己的格式,回避掉需要付给 SUN 有关 JAVA 的授权费用。 对手机制造者的影响 � Android 是款开源的移动计算...