Using Caddy proxy as timeout protection for Rails app

Hi there,
I’d like to use Caddy to abort long running requests to my Rails app.

I have read the proxy docs and found lots of timeout directives, but I don’t know if any of those will help.

My Caddyfile is something like this:

myapp.com {
    gzip
    log stdout
    timeouts 30s

    proxy / 127.0.0.1:3000 {
        transparent
    }

    errors stderr {
        404 public/404.html # Not Found
        422 public/422.html # Unprocessable Entity
        500 public/500.html # Internal Server Error
        503 public/500.html # Service Unavailable
    }
}

If I load a page that doesn’t respond in time the browser gets an error “empty reply from server”. But my app keeps running the request since it is unaware of Caddy’s timeouts.

What I need is a way to make the Caddy proxy abort the request to the app server.
I see some great work in this area has been made already:

It seems like this topic has been discussed already, but it doesn’t seem like a solution has been found.

It would be awesome if I could use Caddy proxy to do the following:

  • Abort the long running request to the app (close the socket) - like a 499 error - which would stop processing immediately
  • Show a nice error page to the user. Maybe a 503 Service Unavailable error? It is better than leaving the browser with an empty response.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.