2

I currently have two apps at AppFog, they are.

http://sru-forums-prod.aws.af.cm/ and http://sru-home-prod.aws.af.cm/

I have haProxy running locally on my computer, this is my current config file.

global debug

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

The end-goal is that localhost:8232 forwards traffic to sru-home-prod, while localhost:8232/forums/* forwards traffic to sru-forums-prod. However I cant even get a simple proxy up and running.

When I run HAProxy off this config file I receive AppFog 404 Not Found at localhost:8232.

What am I missing, is this even possible?

EDIT:

New config works but now i have a port 60032 coming back in the response.

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
James Black
  • 102
  • 1
  • 7

1 Answers1

2

The reason you are getting an AppFog 404 Not Found is because applications hosted on AppFog are routed by domain name. In order for AppFog to know what app to serve you, the domain name is required to be in the HTTP request. When you go to localhost:8232/forums/ it sends localhost as the domain name which AppFog does not have as a registered app name.

There is a good way to get around this issue

1) Map your application to a second domain name, for example:

af map <appname> sru-forums-prod-proxy.aws.af.cm

2) Edit your /etc/hosts file and add this line:

127.0.0.1   sru-forums-prod-proxy.aws.af.cm

3) Go to http://sru-forums-prod-proxy.aws.af.cm:8232/forums/ which will map to the local machine but will go through your haproxy successfully ending up with the right host name mapped to your app hosted at AppFog.

Here is a working haproxy.conf file that demonstrates how this has worked for us so far using similar methodologies.

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
cardmagic
  • 241
  • 1
  • 3
  • Is it possible to do this using only HAProxy ruleS? I got the edit above setup now, and it seems to be working but the response coming back includes some weird port that causes appfog not to render the right files. 60032 or something. – James Black Sep 26 '12 at 20:00