Skip to content

Instantly share code, notes, and snippets.

@berkayunal
Created July 6, 2015 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkayunal/8965cc583fd6e3442314 to your computer and use it in GitHub Desktop.
Save berkayunal/8965cc583fd6e3442314 to your computer and use it in GitHub Desktop.
Thanks Sean
Hey Sean,
Thanks for your help. Appreciate it much
I have a strange problem, sometimes haproxy cannot match the host.
So it cannot use the backend and connections is being aborted in the browser.
Do you know any solutions for this kind of problem.
I am using HA-Proxy version 1.5.14 2015/07/02
You can see the problem on http://blog.ganipara.com with firebug or similar.
Here is a screenshot also:
http://berkayunal.com/share/sc_1B4AF7FE.png
Some requests are being dropped since hostname does not matches.
If i add a like as "default_backend wwwother" into "frontend http-in" it works.
Thanks
Below is my config.
global
log /dev/log local0
log /dev/log local1 notice
maxconn 4096
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
option dontlognull
option http-server-close
option httpclose
#option redispatch
retries 3
timeout connect 5000
timeout client 10000
timeout server 10000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend http-in
bind *:80
acl host_blog hdr(host) -i blog.mydomain.com
use_backend wwwother if host_blog
backend wwwother
mode http
option httplog
option httpclose
option http-server-close
option forwardfor except 127.0.0.1
balance first
server node-1 10.133.157.XXX:80 check
frontend mysql_cluster
bind 188.166.XXX.XXX:3306
default_backend mysql_cluster
backend mysql_cluster
mode tcp
balance roundrobin
option tcplog
option mysql-check user haproxy_check
server db01 10.133.XXX.XXX:3306 check
server db02 10.133.XXX.XXX:3306 check
listen stats 188.166.XXX.XXX:10000
mode http
stats enable
stats uri /
option httpclose
stats realm Strictly\ Private
stats auth user:pass
@seanmcgary
Copy link

So I think your problem is that your front-end doesnt have a mode specified, and since you havent specified a mode in the global or defaults block, I think haproxy will default to mode tcp rather than mode http. So I would try moving the mode declaration from your backend up to your frontend, otherwise haproxy has no idea what kind of traffic to accept on port 80.

@berkayunal
Copy link
Author

Hey Sean,

That worked man! Thanks so much.
I have added mode http to frontend http-in as you suggested. Awesome

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment