Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I an working on running a few Rails applications through Varnish to provide better caching support which will hopefully be more flexible then the build in page-cache options in rails.

One issue I have stumbled upon is that when a HTTP/50x error is returned from the application server varnish does not serve up the custom error page (e.g. when the rails app raises an exception we render a custom error HTML template) - instead of seeing the 'nice' user friendly error page we see the following text:

Error 503 Service Unavailable

Service Unavailable

Guru Meditation:

XID: 828451354

Varnish cache server

Is there any way to possibly pass the fetched HTML from the backend server to the client? Is it as easy as implementing the sub_error VCL method and using a fetch or pass directive?

Thanks.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Well, I have an answer - and surprisingly the problem wasn't even that varnish wasn't passing on the HTTP/500 response content.

The HTTP/503 error was actually being thrown up when Varnish was timing out while connecting to the backend server, or waiting for bytes to be sent.

Basically, if the connection to the backend was successful, but the backend doesn't send the first byte without a certain timeout period, or there is a delay between sending bytes, Varnish will timeout and return a HTTP/503 error.

The solution is to update the timeout values (and of course, fix up the slow backend server) such as below (as detailed at: http://varnish-cache.org/wiki/VCL):

backend www {
   .host = "www.example.com";
   .port = "http";
   .connect_timeout = 1s;
   .first_byte_timeout = 5s;
   .between_bytes_timeout = 2s;
}
share|improve this answer
    
Please mark this as the answer to your question :) –  pauska Jul 7 '10 at 5:46
    
Awesome! That was exactly what I needed. Thanks. –  Brad F Jacobs Sep 26 '12 at 20:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.