Chinaunix

标题: 紧急求助--有关apache转发 [打印本页]

作者: chengxiaowei    时间: 2009-03-25 16:54
标题: 紧急求助--有关apache转发
各位高手,小弟最近被一个域名转发的问题搞死了。
要求如下:
(1)       内网和外网访问http://shis.test.com.cn时,看到的是www.sohu.com的主页        ---成功实现
(2)       内网和外网访问http://shis.test.com.cn/pca/时,看到的是pca的登录界面            ---如果NAT出去,比如我的机器正常,但是加了代理就会自动转发到www.test.com主页。但是如果输入https://shis.test.com.cn/pca 的话,访问就正常了。
(3)       内网和外网访问http://shis.test.com.cn/mrtg/时,看到的是mrtg的登录界面  ---故障同上

(4)       内网和外网访问http://shis.test.com.cn/的除了pca和mrtg目录以外的所有不存在的目录和网页时,看到的是www.test.com的主页 --成功实现
(5)       内网用户访问http://imchina.test.com.cn/时,看到的是文具申请的网站。外网用户无法登录文具申请网站。--成功实现

我们公司里面是用squid做代理上网的,如果我用代理上网去上shis.globalsources.com.cn/pca的时候,会自动跳转到www.sohu.com,如果我输入https://shis.globalsources.com.cn/pca时,访问正常。 如果我是通过IPTABLES NAT出去的话,那么一切正常。
我已经实现了1 4 5要求,2 3的要求我觉得是还差一点点,但是就是这一点点我过不去了,请各位大哥帮忙看看怎么弄才能完成这个转

发。  
顺便说一下,我还发现一个问题,就是我ping shis.test.com.cn的时候,出现的是线路2(外网IP)的地址。
最后说一下,我们一个资深工程师领导说这个只要设置httpd-vhost.conf就可以了。其他都不需要管的。   万分感谢大家!!!

我还看了error_log,显示出来的错误提示如下:
[Wed Mar 25 16:05:22 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/favicon.ico
[Wed Mar 25 16:05:32 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/stationery/mrtg
[Wed Mar 25 16:05:38 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/stationery/pca
[Wed Mar 25 16:13:24 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/favicon.ico
[Wed Mar 25 16:38:59 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/favicon.ico
[Wed Mar 25 16:44:00 2009] [error] [client 192.168.11.5] File does not exist: /data/imchina/stationery/mrtg

上网服务器 A-192.168.11.5  ---作为apache转发,外面有人访问192.168.11.8上的网站的时候,自动转发给192.168.11.8的网页
httpd-vhosts.conf中的内容
NameVirtualHost 线路2:80    --外网IP:80
NameVirtualHost 线路2:443  --外网IP:443
NameVirtualHost 192.168.11.5:80

<VirtualHost 192.168.11.5:80>
servername 192.168.11.5
ServerAdmin helpdesk@test.com
DocumentRoot /data/sarg
<Directory "/data/sarg">
    Options None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost 线路2:443>
ServerName shplus.test.com
ServerAdmin helpdesk@test.com
ErrorLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/error_log"
TransferLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/access_log"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP:+eNULL
SSLCertificateFile /etc/certs/shplus.crt
SSLCertificateKeyFile /etc/certs/shplus.key
CustomLog /usr/local/apache/logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
SSLProxyEngine on
RewriteEngine on
RewriteRule ^/(.*)$ https://shplus.test.com/$1 [P,L]
</VirtualHost>

<VirtualHost 线路2:80>
ServerName shplus.test.com
ServerAdmin helpdesk@test.com
ErrorLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/error_log"
TransferLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/access_log"
RewriteEngine on
RewriteRule ^/(.*)$ https://shplus.test.com/$1 [R,L]
</Virtualhost>

<VirtualHost 线路2:443>
ServerName shis.test.com.cn
ServerAdmin helpdesk@test.com
ErrorLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/error_log"
TransferLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/access_log"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP:+eNULL
SSLCertificateFile /etc/certs/sh.crt
SSLCertificateKeyFile /etc/certs/sh.key
CustomLog /usr/local/apache/logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
SSLProxyEngine on
RewriteEngine on
RewriteRule ^/(.*)$ https://shis.test.com.cn/$1 [P,L]
</VirtualHost>

<VirtualHost 线路2:80>
ServerName shis.test.com.cn
ServerAdmin helpdesk@test.com
ErrorLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/error_log"
TransferLog "|/usr/local/sbin/cronolog /var/log/apache/shis/%Y/%m/%d/access_log"
RewriteEngine on
RewriteRule ^/(.*)$ https://shis.test.com.cn/$1 [R]
#RewriteRule ^/(.*)$ https://shis.test.com.cn/$1 [P,L]
</Virtualhost>


网页服务器B -192.168.11.8
httpd-vhosts.conf的内容
NameVirtualHost *:80
<VirtualHost *:80>
ServerName imchina.test.com.cn
ServerAdmin sh-mss-helpdesk@test.com
DocumentRoot "/data/imchina"
RewriteEngine on
RewriteRule ^/(.*)$ https://imchina.test.com.cn/stationery/$1 [R,L]

<Directory "/data/imchina">
        Options  FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

</VirtualHost>


<VirtualHost *:80>
    ServerAdmin test@test.com
    ServerName shis.test.com.cn
RewriteEngine on
#RewriteRule ^/(.*)$ http://www.sohu.com/ [R,L]
RewriteRule ^/(.*) http://www.sohu.com/ [L]

<Directory "/data/pca">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

<Directory "/data/mrtg">
        Options Indexes FollowSymLinks
        AllowOverride AuthConfig
       Order allow,deny
       Allow from all
</Directory>

<IfModule alias_module>
Alias /pca "/data/pca/"
Alias /mrtg "/data/mrtg/"
</IfModule>

</VirtualHost>
作者: chengxiaowei    时间: 2009-03-26 08:18
请高手帮帮忙吧,这个问题实在让我头晕了。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2