title: HaProxy - Direct to backend server according to query string
body: <p>I am using HaProxy to load balance between my 2 servers. My mobile app connects to one of this 2 servers directed by the loadbalancer. My apps mainly makes this http request to loadbalancer:</p>
  
  <p><a href="http://www.example.com/file.php?action=getdata" rel="nofollow noreferrer">http://www.example.com/file.php?action=getdata</a></p>
  
  <p>and this is being redirected to one of these 2 servers and there is no problem with this but I need this requests to direct to server2 always because these specific actions are stored on the database of server2.</p>
  
  <p><a href="http://www.example.com/file.php?action=gettoken" rel="nofollow noreferrer">http://www.example.com/file.php?action=gettoken</a> OR
  <a href="http://www.example.com/file.php?action=savetoken" rel="nofollow noreferrer">http://www.example.com/file.php?action=savetoken</a></p>
  
  <p>How can I achieve this with haproxy's config file ? Currently it looks like:</p>
  
  <pre><code>frontend haproxynode
  bind *:80
  mode http
  default_backend backendnodes
  backend backendnodes
  balance roundrobin
  option forwardfor
  http-request set-header X-Forwarded-Port %[dst_port]
  http-request add-header X-Forwarded-Proto https if { ssl_fc }
  option httpchk HEAD / HTTP/1.1\r\nHost:localhost
  server node1 ip:80 check
  server node2 ip:80 check
  </code></pre>