ITeye博客

squid 2.6 反向代理配置

无明 · 2007-06-15 17:27 · 安装配置 · 操作系统 · Markdown

http_port 192.168.1.233:80 defaultsite=192.168.1.150 vhost vport=80
cache_peer 192.168.1.150 parent 80 0 no-query originserver
cache_peer 192.168.1.233 parent 100 0 no-query originserver
cache_peer_domain 192.168.1.150 www.xx.cn
cache_peer_domain 192.168.1.233 www.aa.cn

acl all src 0.0.0.0/0.0.0.0
acl Safe_ports port 80
acl Safe_ports port 443
http_access deny !Safe_ports
http_access allow all

refresh_pattern -i .  0 100% 0 reload-into-ims

只有一个IP,但是有几台机器要发布到internet上,便想起用squid来做个反向代理,只是起转发请求的作用,不缓存东西。

评论(4)

  1. #4 楼 · 无明 · 2007-06-15 23:55

    apache 虚拟主机加 mod-proxy当然也可以,但效率上就不能跟squid相比了

  2. #3 楼 · codeutil · 2007-06-15 22:58

    apache 虚拟主机加 mod-proxy可以不???

    
    
    NameVirtualHost *
    
    <VirtualHost *>
        ServerAdmin admin@www.xx.cn
        DocumentRoot /www/docs/www.xx.cn
        ServerName www.xx.cn
        ServerAlias ww.xx.cn
        ErrorLog logs/www.xx.cn-error_log 
        CustomLog logs/www.xx.cn-access_log common
        <Location /balancer-manager>
    SetHandler balancer-manager
    Order allow,deny
    Allow from 127.0.0.1
    Allow from localhost
    </Location>
        
    ProxyPass /balancer-manager !
    ProxyPass / balancer://tomcatcluster/  lbmethod=byrequests stickysession=JSESSIONID  nofailover=Off timeout=30  maxattempts=3
    ProxyPassReverse / balancer://tomcatcluster/
    
    <Proxy balancer://tomcatcluster>
    BalancerMember http://192.168.1.150 loadfactor=10 smax=10 max=10 ttl=5 timeout=30 acquire=3  route=tomcat12080
    </Proxy>
    </VirtualHost>
    
    <VirtualHost *>
        ServerAdmin admin@www.aa.cn
        DocumentRoot /www/docs/www.aa.cn
        ServerName www.aa.cn
        ServerAlias ww.aa.cn
        ErrorLog logs/www.aa.cn-error_log 
        CustomLog logs/www.aa.cn_log common
        <Location /balancer-manager>
    SetHandler balancer-manager
    Order allow,deny
    # 允许本机自身访问
    Allow from 127.0.0.1
    Allow from localhost
    </Location>
    
        
    ProxyPass /balancer-manager !
    ProxyPass / balancer://tomcatcluster/  lbmethod=byrequests stickysession=JSESSIONID  nofailover=Off timeout=30  maxattempts=3
    ProxyPassReverse / balancer://tomcatcluster/
    
    <Proxy balancer://tomcatcluster>
    BalancerMember http://192.168.1.233 smax=10 max=10 ttl=5 timeout=30 acquire=3  route=tomcat11080
    </Proxy>
    
    </VirtualHost>
    
    
    
    
    
    

    这样应该也可以满足需求.

  3. #2 楼 · 无明 · 2007-06-15 19:49

    各自独立,而且运行的端口不一,但都要求以80对外提供服务。简单的端口映射不能解决,不然我用路由或者iptables就可以了,也不用装啥软件。

  4. #1 楼 · glassprogrammer · 2007-06-15 19:09

    想问一下你这几台机器是不是各自独立的, 发布出来的应用也不需要使用同一个端口吧, 如果这样何不试试 yap 端口映射工具呢?

    http://sourceforge.net/projects/yap-mu/

    当然, 如果你要在 linux 下跑算我没说, 呵呵.

评论功能维护中,当前仅展示历史评论。