I want to create a simple load balancer for the two servers.
The problem is with CNAME records, I think.
Let's say I have two the same applications on AppFog.com.
app1.aws.af.cm and app2.aws.af.cm
Here is my haproxy.cfg file:
global
maxconn 2000
daemon
defaults
mode http
clitimeout 60000
srvtimeout 30000
contimeout 4000
option httpclose
listen http_proxy
bind [myip]:80
mode http
stats enable
stats auth user:passwd
stats uri /stats
balance source
option httpchk
option forwardfor
server host01 app1.aws.af.cm:80 maxconn 300 check
server host02 app2.aws.af.cm:80 maxconn 300 check
But this only resolving IP for domain app1.aws.af.cm and app2.aws.af.cm, which obviously doesn't work if I open this IP in web browser.
The problem is that AppFog doesn't have public IP for application (same as OpenShift).
How to do that Haproxy to perform a proper connection between Load Balancer and this two servers?
Example:
This is real app – http://freechat.eu01.aws.af.cm
Haproxy only resolves IP for this domain which is 46.51.204.8:80
Of course this IP will not show my application, only an error page.
Sorry for my poor English.
Best Answer
Having a little trouble following your issue. However, one thing to keep in mind is that HTTP requests have the requested domain name as the Host field in the HTTP header.
Therefore load balancers and web servers will generally direct the request or respond to the request if the name binding matches the host header.
Perhaps this clears things up a little, or maybe you can try to rephrase your question?