51Degrees / Device-Detection

THE Fastest and most Accurate device detection for C / PHP / Perl / Python and Node.js - professionally maintained device data
https://51degrees.com/device-detection
Other
112 stars 46 forks source link

HAProxy support seems to be broken with new htx represenation enabled #44

Closed albix closed 4 years ago

albix commented 4 years ago

We switched from HAProxy 1.9.10 to 2.0.12 and enabled the new htx representation. This option seems to break the device detection. With htx disabled it works as expected. I opened https://github.com/haproxy/haproxy/issues/450 as well.

haproxy.cfg

global
  chroot /tmp/haproxy
  user haproxy
  group haproxy

  51degrees-data-file /tmp/haproxy/51Degrees-PremiumV3.4.trie
  51degrees-property-name-list IsMobile LayoutEngine ScreenPixelsHeight ScreenPixelsWidth DeviceType HardwareFamily HardwareName PlatformName JavascriptVersion BrowserName BrowserVersion IsCrawler

defaults
  mode http
  #no option http-use-htx

frontend foo
  bind *:10000
  http-request set-header X-51D-DeviceType %[51d.all(DeviceType)]
  http-request set-header X-51D-HardwareFamily %[51d.all(HardwareFamily)]
  http-request set-header X-51D-PlatformName %[51d.all(PlatformName)]
  http-request set-header X-51D-LayoutEngine %[51d.all(LayoutEngine)]
  http-request set-header X-51D-JavascriptVersion %[51d.all(JavascriptVersion)]
  http-request set-header X-51D-BrowserName %[51d.all(BrowserName)]
  http-request set-header X-51D-BrowserVersion %[51d.all(BrowserVersion)]
  http-request set-header X-51D-IsCrawler %[51d.all(IsCrawler)]

  http-request set-header Host httpbin.org
  default_backend bar

backend bar
  # httpbin.org
  server s1 34.193.212.251:80
  server s2 54.172.95.6:80

actual behaviour

$ curl -H "accept: application/json" http://127.1:10000/anything
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.29.0", 
    "X-51D-Browsername": "1", 
    "X-51D-Browserversion": "1", 
    "X-51D-Devicetype": "1", 
    "X-51D-Hardwarefamily": "1", 
    "X-51D-Iscrawler": "1", 
    "X-51D-Javascriptversion": "1", 
    "X-51D-Layoutengine": "1", 
    "X-51D-Platformname": "1"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "<deducted>", 
  "url": "https://httpbin.org/anything"
}

expected behaviour

$ curl -H "accept: application/json" http://127.1:10000/anything
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.29.0", 
    "X-51D-Browsername": "Unknown Crawler", 
    "X-51D-Browserversion": "Unknown", 
    "X-51D-Devicetype": "Desktop", 
    "X-51D-Hardwarefamily": "Emulator", 
    "X-51D-Iscrawler": "True", 
    "X-51D-Javascriptversion": "Unknown", 
    "X-51D-Layoutengine": "Unknown", 
    "X-51D-Platformname": "Unknown"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "<deducted>", 
  "url": "https://httpbin.org/anything"
}
ben51degrees commented 4 years ago

Hi @albix, I will close this and keep https://github.com/haproxy/haproxy/issues/450 as the main thread. The patch is submitted and waiting to be applied.