HAProxy - Configure HTTP frontend to listen on multiple ports

青春壹個敷衍的年華 提交于 2019-12-23 07:06:02

问题


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?


回答1:


Try this in your frontend section:

bind :80
bind :8080



回答2:


bind 0.0.0.0:80
bind 0.0.0.0:8080

Works for me !



来源:https://stackoverflow.com/questions/20082761/haproxy-configure-http-frontend-to-listen-on-multiple-ports

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!