4

Is there any way to configure HAProxy to convert GET requests to POST when sending to the backend servers?

The background of the problem is that we want to use a Cloud based logging service (e.g. loggy.com), which only allows log events to be created via POST to its REST API. Log events will be created via Javascript in a browser when our widget is loaded onto webpages, thus we can't do POST because of CSRF prevention.

Is there a better way to do this besides setting up a proxy that converts GETs into POSTs?

cjbottaro
  • 141
  • 3

2 Answers2

3

Something like this should do the trick:

backend HttpServers
  mode http
  balance roundrobin
  option httpchk
  reqirep ^GET\s+(https?:/.*)$ POST\ \1

The key bit is the last line.

nbevans
  • 742
  • 1
  • 6
  • 13
0

I'd recommend against generating the events in javascript on the client browser, for a multitude of reasons, security foremost.

Work with the vendor you choose to determine the best way to bring your web server logs into the service, but grabbing out that text file instead of trying to get client browsers to send requests directly to the event API will make your life much easier.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251