Welcome! Log In Create A New Profile

Advanced

Re: How to set Retry-After for 503?

Gena Makhomed
July 03, 2009 03:46PM
On Friday, July 3, 2009 at 21:01:18, tmiskiew wrote:

t> Can you please explain how to set Retry-After for the status code 503?

workaround via ngx_http_perl_module:

> cat /etc/nginx/perl/erorr503.pm
package error503;
use warnings;
use strict;
use nginx;

sub handler {
my $r = shift;
$r->status( 503 );
$r->header_out( 'Retry-After', 600 );
$r->send_http_header( 'text/html' );
$r->print(
"<html>"."\x0d\x0a".
"<head><title>503 Service Temporarily Unavailable</title></head>"."\x0d\x0a".
"<body bgcolor=\"white\">"."\x0d\x0a".
"<center><h1>503 Service Temporarily Unavailable</h1></center>"."\x0d\x0a".
"<hr><center>nginx</center>"."\x0d\x0a".
"</body>"."\x0d\x0a".
"</html>"."\x0d\x0a"
);
}

1;

> cat /etc/nginx/conf/nginx.conf
# ...
http {
server_tokens off;
perl_modules /etc/nginx/perl;
perl_require erorr503.pm;

server {
server_name error503;
error_page 503 = @error503;
location @error503 { perl error503::handler; }
location /error503 { return 503; }
}
# ...

> curl http://error503/error503 -D headers
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

> cat headers
HTTP/1.1 503 Service Temporarily Unavailable
Server: nginx
Date: Fri, 03 Jul 2009 19:30:47 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Retry-After: 600

--
Best regards,
Gena
Subject Author Posted

How to set Retry-After for 503?

tmiskiew July 03, 2009 11:00AM

Re: How to set Retry-After for 503?

Gena Makhomed July 03, 2009 12:13PM

Re: How to set Retry-After for 503?

tmiskiew July 03, 2009 02:01PM

Re: How to set Retry-After for 503?

Gena Makhomed July 03, 2009 03:46PM

Re: How to set Retry-After for 503?

Gena Makhomed July 03, 2009 03:49PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 103
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready