Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy - Configure HTTP frontend to listen on multiple ports

Tags:

haproxy

I have an HAProxy HTTP Frontend in my HAProxy config like so:

frontend myaddress.net :10098
  bind :80,:8080
  mode http
  log global
  option http-server-close
  timeout client 14400000
  timeout connect 60000
  timeout tunnel 14400000
  timeout http-request 14400000
  capture request header User-Agent len 64
  capture request header Accept-language len 64
  capture request header x-forward len 15
  capture request header host len 64
  capture request header X-Orig-Base len 64
  capture request header X-Orig-Host len 64
  capture request header X-Orig-Proto len 64

  reqadd X-Original-host:\ myaddress.net

  acl is-ssl hdr(X-Orig-Proto) https
  acl is-http hdr(X-Orig-Proto) http

  redirect code 301 prefix https://myaddress.net if is-http

  default_backend BACKEND_myaddress.net:catchall

It points to a backend defined like so:

backend BACKEND_myaddress.net:catchall
  timeout server 4h
  balance leastconn
  server myserver myserver:8080 check inter 5s rise 3 fall 1

I've got it working to listen on port 80, then forward to 8080 on the backend server, but now I'm trying to make it also listen on port 8080 on the frontend (don't ask me why, it's a lame requirement).

As you can see, I've got a line that says bind :80,:8080. I thought that would make the frontend also listen on port 8080, but it's not appearing to listen on port 8080.

Is there something I'm missing in this configuration? How can I make a frontend listen on port 8080 and 80, which then forwards to the backend server on port 8080?

like image 958
dsw88 Avatar asked Nov 19 '13 21:11

dsw88


2 Answers

Try this in your frontend section:

bind :80
bind :8080
like image 108
Gooner Avatar answered Nov 15 '22 08:11

Gooner


bind 0.0.0.0:80
bind 0.0.0.0:8080

Works for me !

like image 44
Karthik Avatar answered Nov 15 '22 09:11

Karthik