Mass Virtual Hosting 到底怎么实现啊?捆饶已久

发表于:2007-05-25来源:作者:点击数: 标签:
MassVirtualHosting Description: TheVirtualHostfeatureofApacheisniceandworksgreatwhenyoujusthaveafewdozensvirtualhosts.ButwhenyouareanISPandhavehundredsofvirtualhoststoprovidethisfeatureisnotthebestchoice. Solution: Toprovidethisfeaturewema

Mass Virtual Hosting
Description: 
The <VirtualHost> feature of Apache is nice and works great when you just have a few dozens virtual hosts. But when you are an ISP and have hundreds of virtual hosts to provide this feature is not the best choice. 
Solution: 
To provide this feature we map the remote webpage or even the complete remote webarea to our namespace by the use of the Proxy Throughput feature (flag [P]): ##
##  vhost.map 
## 
www.vhost1.dom:80  /path/to/docroot/vhost1
www.vhost2.dom:80  /path/to/docroot/vhost2
     :
www.vhostN.dom:80  /path/to/docroot/vhostN
 
##
##  httpd.conf
##
    :
#   use the canonical hostname on redirects, etc.
UseCanonicalName on

    :
#   add the virtual host in front of the CLF-format
CustomLog  /path/to/aclearcase/" target="_blank" >ccess_log  "%{VHOST}e %h %l %u %t \"%r\" %>s %b"
    :

#   enable the rewriting engine in the main server
RewriteEngine on

#   define two maps: one for fixing the URL and one which defines
#   the available virtual hosts with their corresponding
#   DocumentRoot.
RewriteMap    lowercase    int:tolower
RewriteMap    vhost        txt:/path/to/vhost.map

#   Now do the actual virtual host mapping
#   via a huge and complicated single rule:
#
#   1. make sure we don't map for common locations
RewriteCond   %{REQUEST_URI}  !^/commonurl1/.*
RewriteCond   %{REQUEST_URI}  !^/commonurl2/.*
    :
RewriteCond   %{REQUEST_URI}  !^/commonurlN/.*
#
#   2. make sure we have a Host header, because
#      currently our approach only supports 
#      virtual hosting through this header
RewriteCond   %{HTTP_HOST}  !^$
#
#   3. lowercase the hostname
RewriteCond   ${lowercase:%{HTTP_HOST}|NONE}  ^(.+)$
#
#   4. lookup this hostname in vhost.map and
#      remember it only when it is a path 
#      (and not "NONE" from above)
RewriteCond   ${vhost:%1}  ^(/.*)$
#
#   5. finally we can map the URL to its docroot location 
#      and remember the virtual host for logging puposes
RewriteRule   ^/(.*)$   %1/$1  [E=VHOST:${lowercase:%{HTTP_HOST}}]
    : 
 

按照上边做的,好象没有用,加不加都一样。
我用的是apache 1.3.17, 应该包含 rewrite模块了吧(重新启动httpd,不报错误,说明认识 rewriteengine等指令) 为什么 url rewrite 不起作用?

 kelei 回复于:2003-05-04 23:41:27
高手快点来啊

。。。。。。。。

 kelei 回复于:2003-05-05 09:30:08
鼎鼎顶

 mb 回复于:2003-05-05 13:06:45
去了httpd.conf下的virtualhost语句
用miss virtual hosts时,不要再用virtualhost了

 kelei 回复于:2003-05-05 15:59:59
两者有冲突,不能混用吗?

 kelei 回复于:2003-05-05 16:00:19
[quote:ccde805755="mb"]去了httpd.conf下的virtualhost语句
用miss virtual hosts时,不要再用virtualhost了[/quote:ccde805755]

两者有冲突,不能混用吗?

 kelei 回复于:2003-05-05 19:17:51
[quote:4c8e9d710a="mb"]去了httpd.conf下的virtualhost语句
用miss virtual hosts时,不要再用virtualhost了[/quote:4c8e9d710a]

我试着去掉 virtualhost, 可以网站都不能访问了啊,
应该怎么做啊?

 kelei 回复于:2003-05-06 22:46:37


 kelei 回复于:2003-05-09 09:30:56
人气好差阿,高手们哪里去了?

 HonestQiao 回复于:2003-05-09 09:52:35
先说说你要达到什么样的效果

rewrite可以做得很的事情很多很多的

如果只是一般的子目录跳转

不必要virtualhost设置的

 kelei 回复于:2003-05-09 18:16:36
[quote:b89a2d32c4="HonestQiao"]先说说你要达到什么样的效果

rewrite可以做得很的事情很多很多的

如果只是一般的子目录跳转

不必要virtualhost设置的[/quote:b89a2d32c4]

就像上边所说的  mass virtualhost
想用rewrite实现virtualhost, 省的改httpd.conf
简化管理

 kelei 回复于:2003-05-12 11:28:16
Mass Virtual Hosting 


真的没有人能帮我吗?

 macleo 回复于:2003-05-12 12:56:28
顶了再说!

 mb 回复于:2003-05-12 14:28:25
选确定你的apache的httpd.conf中是在编译中加入了rewrite_module支持,要是没有的话当然是不行了,你的vhost.map文件能被apache组用户有r权限吗?

 mb 回复于:2003-05-12 14:29:38
是的,不能同时用,你用了vhost.map还用virtualhost做什么,有方但的还用哪个老的做什么

 kelei 回复于:2003-05-13 12:30:19
[quote:af8866a4ef="mb"]选确定你的apache的httpd.conf中是在编译中加入了rewrite_module支持,要是没有的话当然是不行了,你的vhost.map文件能被apache组用户有r权限吗?[/quote:af8866a4ef]

我的httpd.conf 加入了rewrite_module支持,而且在.htaccess文件中设置过,也证实了是起作用的

我的vhost.map文件权限设置 777

我把 conf 文件中 virtual host 的所有条目都注释掉了,还是不行

请问,会有别的可能的原因吗?

我的apache 1.3.17

 mb 回复于:2003-05-13 13:38:27
apache 1.3.17是您编译时加入了rewrite了,有mod_rewrite.so吗,默认是没有的
vhost中的域名是谁为您解析的,要是能正常指向您服务器的ip的话,哪么您要是能确定rewrite_module以被加载
在不能访问时出现了什么提示(apache要是能解析说明您的web页路径不对)

 kelei 回复于:2003-05-14 20:31:42
[quote:06a25c13e4="mb"]apache 1.3.17是您编译时加入了rewrite了,有mod_rewrite.so吗,默认是没有的
vhost中的域名是谁为您解析的,要是能正常指向您服务器的ip的话,哪么您要是能确定rewrite_module以被加载
在不能访问时出现了什么提?.........[/quote:06a25c13e4]
rewrite.so是静态模块,不需要静态的和apache编译到一起吧?
我的系统里有rewirte.so文件
httpd.conf文件中有 load module 和 addmodule  相关语句, 而且在 htaccess中设置 rewrite 是有效果的,这可以说明 apache没有问题吧

domain解吸也是没有问题的

Apache的提示就是"找不到网页 
您要查看的网页可能已被删除、名称已被更改,或者暂时不可用。 
"

 mb 回复于:2003-05-15 08:22:47
The vhost.map file contains something like this:

www.customer-1.com  /www/customers/1
www.customer-2.com  /www/customers/2
# ...
www.customer-N.com  /www/customers/N



The http.conf contains this:

RewriteEngine on

RewriteMap   lowercase  int:tolower

# define the map file
RewriteMap   vhost      txt:/www/conf/vhost.map

# deal with aliases as above
RewriteCond  %{REQUEST_URI}               !^/icons/
RewriteCond  %{REQUEST_URI}               !^/cgi-bin/
RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$
# this does the file-based remap
RewriteCond  ${vhost:%1}                  ^(/.*)$
RewriteRule  ^/(.*)$                      %1/docs/$1

RewriteCond  %{REQUEST_URI}               ^/cgi-bin/
RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$
RewriteCond  ${vhost:%1}                  ^(/.*)$
RewriteRule  ^/(.*)$                      %1/cgi-bin/$1

请按以上格式改写一下

 kelei 回复于:2003-05-15 13:04:10
按照您给的例子做了,错误依旧!

 ykeyhome 回复于:2003-05-27 09:24:20
up

原文转自:http://www.ltesting.net