Php 在Appfog上设置haProxy以切换多个应用程序的内容

Php 在Appfog上设置haProxy以切换多个应用程序的内容,php,node.js,haproxy,appfog,Php,Node.js,Haproxy,Appfog,我目前在AppFog有两个应用程序,它们是 及 我的计算机上本地运行haProxy,这是我当前的配置文件 全球的 调试 defaults mode http timeout connect 500ms timeout client 50000ms timeout server 50000ms backend legacy server forums sru-forums-prod.aws.af.cm:80 frontend app *:8232 default_bac

我目前在AppFog有两个应用程序,它们是

我的计算机上本地运行haProxy,这是我当前的配置文件

全球的 调试

defaults
  mode http
  timeout connect 500ms
  timeout client 50000ms
  timeout server 50000ms

backend legacy
  server forums sru-forums-prod.aws.af.cm:80

frontend app *:8232
  default_backend legacy
最终目标是localhost:8232将流量转发给sru home prod,而localhost:8232/forums/*将流量转发给sru-forums-prod。然而,我甚至无法启动并运行一个简单的代理

当我在这个配置文件下运行HAProxy时,我收到了在localhost:8232上找不到的AppFog 404

我错过了什么,这可能吗

编辑:

新的配置可以工作,但现在我有一个端口60032返回到响应中

global
  debug

defaults
  mode http
  timeout connect 500ms
  timeout client 50000ms
  timeout server 50000ms

backend legacy
  option forwardfor
  option httpclose
  reqirep ^Host: Host:\ sru-forums-prod.aws.af.cm
  server forums sru-forums-prod.aws.af.cm:80

frontend app *:8000
  default_backend legacy

找不到AppFog 404的原因是,AppFog上承载的应用程序按域名路由。为了让AppFog知道为您服务的应用程序,HTTP请求中必须包含域名。当您转到localhost:8232/forums/时,它会将localhost作为域名发送,而AppFog没有将其作为注册的应用程序名

有一个很好的方法来回避这个问题

1) 将应用程序映射到第二个域名,例如:

af map <appname> sru-forums-prod-proxy.aws.af.cm
3) 转到将映射到本地计算机,但将通过haproxy成功结束,并将正确的主机名映射到AppFog托管的应用程序

下面是一个正在工作的haproxy.conf文件,它演示了到目前为止我们如何使用类似的方法来实现这一点

defaults
  mode http
  timeout connect 500ms
  timeout client 50000ms
  timeout server 50000ms

backend appfog
  option httpchk GET /readme.html HTTP/1.1\r\nHost:\ aroundtheworld.appfog.com
  option forwardfor
  option httpclose
  reqirep ^Host: Host:\ aroundtheworld.appfog.com
  server pingdom-aws afpingdom.aws.af.cm:80 check
  server pingdom-rs afpingdom-rs.rs.af.cm:80 check
  server pingdom-hp afpingdom-hp.hp.af.cm:80 check
  server pingdom-eu afpingdom-eu.eu01.aws.af.cm:80 check
  server pingdom-ap afpingdom-ap.ap01.aws.af.cm:80 check

frontend app *:8000
  default_backend appfog

listen stats 0.0.0.0:8080
    mode http
    stats enable
    stats uri /haproxy

是否可以仅使用HAProxy规则执行此操作?我现在得到了上面的编辑设置,它似乎正在工作,但返回的响应包括一些奇怪的端口,导致appfog无法呈现正确的文件。60032什么的。
defaults
  mode http
  timeout connect 500ms
  timeout client 50000ms
  timeout server 50000ms

backend appfog
  option httpchk GET /readme.html HTTP/1.1\r\nHost:\ aroundtheworld.appfog.com
  option forwardfor
  option httpclose
  reqirep ^Host: Host:\ aroundtheworld.appfog.com
  server pingdom-aws afpingdom.aws.af.cm:80 check
  server pingdom-rs afpingdom-rs.rs.af.cm:80 check
  server pingdom-hp afpingdom-hp.hp.af.cm:80 check
  server pingdom-eu afpingdom-eu.eu01.aws.af.cm:80 check
  server pingdom-ap afpingdom-ap.ap01.aws.af.cm:80 check

frontend app *:8000
  default_backend appfog

listen stats 0.0.0.0:8080
    mode http
    stats enable
    stats uri /haproxy