0

i'm trying to configure haproxy on a red hat 7.1 machine (haproxy 1.5.4)

to proxy a few nodejs instances.

if i try to access on port 80 (haproxy frontend) it returns error 503 if i try to access on port 3000 (node app service), it returns ok

here my haproxy configuration:

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
frontend  main *:80
    default_backend             app
backend app
    balance     roundrobin
    server  app1 127.0.0.1:3000 check

Any guidance is welcome.

Sombriks
  • 141

1 Answers1

1

Thanks everyone for the help, the problem was selinux. more details on this thread: Weird interaction with systemctl with Haproxy on CentOS 7

all i needed to make was to run this command:

sudo semanage port --add --type http_port_t --proto tcp 3000

and changed my config file to this:

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     1000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend  main 0.0.0.0:80
    default_backend             app

backend app
    balance     roundrobin
    server  app1 127.0.0.1:3000 check
Sombriks
  • 141