HAProxy community

Service failed when check is added

#1

Hello everyone
I am trying to configure a sample of HAProxy and I am running into some difficults…
part of the configuration:
frontend firstbalance
bind *:80
option forwardfor
default_backend webservers

backend webservers
balance roundrobin
server web1 172.217.21.238
server web2 98.138.219.232

Problem 1- when I change the port " bind *:80 " to another port, the service is OK but I can’t reach nothing. (when I google ip:port)

Problem 2- adding ‘check’ option makes the service failed

backend webservers
balance roundrobin
server web1 172.217.21.238 check
server web2 98.138.219.232 check

could you please help me solve this?
And if you have some tips for beginners that would be great

0 Likes

#2

What does it mean the service is okay? If you are unable to bind the HAProxy to port 80, it means either the HAProxy service don’t have the privileges to bind to port 80 or there is another service already running on port 80. You can use netstat command to view the services bounded to the ports.

Add :80 with the check line and make sure the HAProxy server is able to connect to port 80 on the backend servers.

server web1 172.217.21.238:80 check
server web2 98.138.219.232:80 check

0 Likes

#3

hey thank you for your help and soory I didn’t explain myself good.
problem 1- in port 80 everything is ok, I can enter ip:80 and it works fine, the service of haproxy on the server is active.
when I change the " bind *:80 " to another port, for example " bind *:8080 " the service is still active but I cannot access a webserver with the ip:8080.

problem 2- when I configure " bind *:80 ", the service is up and I can access a webserver on ip:80 that can do load balancing between 2 working sites.
when I add “check” the service is failed.

0 Likes

#4

May be the firewall is blocking port 8080 that is why you are not able to connect. Have you made sure that no firewall like iptables is blocking your request for port 8080.

The check option problem is still confusing. check performs TCP handshake with the target port (in this case port 80 on the backend) and if it is able to connect, the check condition is passed.

Can you take a look at the HAProxy logs or stats page of HAProxy to determine what is failing the check?

0 Likes

#5

No router blocking.
where can I find the log?

0 Likes

#6
0 Likes