HAProxy community

Nginx location alternative in haproxy

Is this also possible in haproxy?

location /.well-known/matrix/server {
  return 200 '{"m.server": "chat.domain.com:443"}';
  add_header Content-Type application/json;
}

Yes, in 2.2 you can use http-request return:

https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4.2-http-request%20return

In older releases you need a fake backend, with a custom 503 errorfile.

Thanks!

for the impatient:
http-request return status 200 content-type 'application/json; charset=utf-8' string '{"m.server": "xx.xxx.xx:443"}' if { path /.well-known/matrix/server }

(on one line!!!)