Setting up HAProxy to handle multiple incoming ports

Hey everyone, I’m having trouble with my HAProxy setup. I’ve got a frontend that’s working fine on port 80, but I need it to listen on port 8080 too. Here’s what my config looks like:

frontend main
  bind :80,:8080
  mode http
  # other settings...
  default_backend mybackend

backend mybackend
  balance leastconn
  server myapp myapp:8080 check

I thought adding :8080 to the bind line would do the trick, but it’s not working. The frontend still only listens on port 80. Am I missing something obvious here? How can I make it listen on both ports and forward everything to my backend on 8080?

I know it’s a weird requirement, but I gotta make it work somehow. Any help would be super appreciated!

yo, have u tried checkin the logs? sometimes haproxy throws weird errors that dont show up elsewhere. also, make sure ur running haproxy with sudo or as root, cuz it needs special permissions to bind to low ports like 80.

if that doesnt work, maybe try separating the ports into two frontends? just a thought. good luck!

hey there! have u tried using separate bind lines for each port? like:

bind :80
bind :8080

sometimes that works better. also, double-check ur firewall settings? maybe port 8080 is blocked?

whats the reason for needing both ports? sounds interesting! lemme know if u figure it out :slight_smile:

Your configuration looks correct at first glance. Have you verified that HAProxy is actually reloading the new configuration? Sometimes changes don’t take effect if the service isn’t properly restarted.

Another thing to check is your system’s port availability. Run ‘netstat -tuln | grep 8080’ to see if anything else might be binding to that port already.

If those checks don’t reveal the issue, consider enabling more verbose logging in HAProxy. Add ‘log global’ to your frontend section and check the logs for any errors related to port binding.

Lastly, ensure your HAProxy version supports multiple port bindings in this format. Older versions might require a different syntax.