现在的位置: 首页 > 综合 > 正文

play framework学习笔记之 front-end HTTP server

2013年10月29日 ⁄ 综合 ⁄ 共 2229字 ⁄ 字号 评论关闭
文章目录

 

使用lighttpd

Set-up with lighttpd

This example shows you how to configure lighttpd as a front-end web server. Note that you can do the same with Apache, but if you only need virtual hosting or load balancing, lighttpd is a very good choice and much easier to configure!

The /etc/lighttpd/lighttpd.conf file should define things like this:


server.modules = (
      "mod_access",
      "mod_proxy",
      "mod_accesslog" 
)
...
$HTTP["host"] =~ "www.myapp.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" =>
        ( ( "host" => "127.0.0.1", "port" => 9000 ) ) )
}
 
$HTTP["host"] =~ "www.loadbalancedapp.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" => ( 
          ( "host" => "127.0.0.1", "port" => 9000 ), 
          ( "host" => "127.0.0.1", "port" => 9001 ) ) 
    )
}

 

使用apache 代理 play

Set-up with Apache

The example below shows a simple set-up with Apache httpd server running in front of a standard Play configuration.


LoadModule proxy_module modules/mod_proxy.so
...
<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName www.loadbalancedapp.com
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
###########例子代码################################################
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
NameVirtualHost 188.188.1.109:80
<VirtualHost 188.188.1.109:80>
  ServerName 188.188.1.109
  Alias /hy2 "D:/webapp/hy2"
  ProxyPreserveHost On
  ProxyPass / http://188.188.1.109:9000/
  ProxyPassReverse / http://188.188.1.109:9000/
</VirtualHost>

其中注意 http://188.188.1.109:9000/ 最后的那一个 / 很重要
此处除了load模块 proxy_module 外还要导入相对的子 module如 我们这里用到了 http协议,那么就要用到 proxy_http_module这个子模块,此外还有ftp,balancer等其它对应的子模块

 

使用apache负载均衡

 

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

 

<VirtualHost 188.188.1.109:80>

  ServerName 188.188.1.109

  <Location /balancer-manager>

    SetHandler balancer-manager

    Order Deny,Allow

    Deny from all

    Allow from ALL

  </Location>

  <Proxy balancer://mycluster>

    BalancerMember http://localhost:9000                

#这里可以用localhost

    BalancerMember http://localhost:9001 status=+H

#+H的意思是 备用的意思

  </Proxy>

  <Proxy *>

    Order Allow,Deny

    Allow From All

  </Proxy>

  ProxyPreserveHost On

  ProxyPass /balancer-manager !

  ProxyPass / balancer://mycluster/

  ProxyPassReverse / http://localhost:9000/

  ProxyPassReverse / http://localhost:9001/

</VirtualHost>

 

使用了负载均衡了之后如果你的主力服务器挂了,或者在升级,那么的备用的会替换上,接着干

 

【上篇】
【下篇】

抱歉!评论已关闭.