将HAproxy的端口80和443转发到后端的端口80和443。

3

我该如何改进下面的配置,使得haproxy监听80和443端口,并将请求转发到backend:80或backend:443取决于请求的端口。

是否有更好的方法来完成这个任务?

frontend http
    bind    35.154.100.100:80
    default_backend http_nginx_pool

frontend https
    bind    35.154.100.100:443
    default_backend https_nginx_pool

backend http_nginx_pool
    mode tcp
    server nginx2 10.233.32.143:80 check

backend https_nginx_pool
    mode tcp
    server nginx2 10.233.32.143:443 check

你想要“改进”什么? - Michael - sqlbot
1
不太确定,但我觉得肯定有更好的办法来做。 - Jonathan
1个回答

8

我在HAProxy 1.5上进行了测试,效果良好。

frontend http-https-in
bind    35.154.100.100:80
bind    35.154.100.100:443

use_backend http_nginx_pool    if !{ ssl_fc }
use_backend https_nginx_pool   if { ssl_fc }

backend http_nginx_pool
    mode http
    server nginx2 10.233.32.143:80 check

backend https_nginx_pool
    mode http
    server nginx2 10.233.32.143:443 check

太棒了。谢谢你。 - Jonathan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接