Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

ssl - How to use multi-condition with if in use_backend (Haproxy)?

I am using Haproxy to separate http and https with different domain setting, but domain limitation with http not working well. My setting as following. Any idea?

frontend ha_8080
  mode tcp
  bind *:8080
  tcp-request content accept if { req_ssl_hello_type 1 }
  tcp-request inspect-delay 100ms
  tcp-request content accept if HTTP
  acl is_using_ssl req.ssl_hello_type gt 0

  acl is_abc hdr_dom(host) -i abc.com
  use_backend http_server if !is_using_ssl is_abc  #it works and only works on abc.com,
  use_backend local_server1 if is_using_ssl is_abc #https will not working
  use_backend local_server1 if is_using_ssl        #it works, but I need it work only on abc.com


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

hdr_dom(host) not work for https(ssl).

I should change to using req_ssl_sni.

My final setting as following.

frontend ha_8080
  mode tcp
  bind *:8080
  tcp-request content accept if { req_ssl_hello_type 1 }
  tcp-request inspect-delay 100ms
  tcp-request content accept if HTTP
  acl is_abc hdr_dom(host) -i abc.com
  acl is_abc_ssl req_ssl_sni -i abc.com
  use_backend http_server if is_abc 
  use_backend local_server1 if is_abc_ssl 


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...