HAProxy - Configure HTTP frontend to listen on multiple ports
Asked Answered
T

2

17

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?

Tincture answered 19/11, 2013 at 21:46 Comment(0)
G
33

Try this in your frontend section:

bind :80
bind :8080
Gladysglagolitic answered 19/11, 2013 at 22:52 Comment(0)
A
4
bind 0.0.0.0:80
bind 0.0.0.0:8080

Works for me !

Allimportant answered 5/5, 2017 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.