Haproxy without backend

Viewed 355

Is it possible to configure HAProxy without backend and yet not fail, as we would need a HAProxy solely for redirect of url

1 Answers

Not entirely possible (or intended) but using a static file as default backend seems to work:

...
frontend http-in
    bind *:8080
    http-request redirect location https://%[hdr(host),lower,map(/usr/local/etc/haproxy/redirect.map)]%[capture.req.uri] code 301 if { hdr(host),lower,map(/usr/local/etc/haproxy/redirect.map) -m found }
    default_backend kitchen-sink

backend kitchen-sink
    mode http
    errorfile 503 /usr/local/etc/haproxy/errors/kitchen-sink.http
...

With kitchen-sink.http containing:

HTTP/1.0 200 Found
Cache-Control: no-cache
Connection: close
Content-Type: text/plain

200 Found

and redirect.map

# SOURCE -> TARGET
old.example.com new.example.com

Related