Custom 503 Error Page

Corey Donohoe atmos at atmos.org
Sun Feb 3 21:00:02 MSK 2008


On 2/3/08, Douglas A. Seifert <dseifert at searchspark.com> wrote:
>
> test.conf
> ----------------------
> # number of nginx workers
> worker_processes  6;
>
> # pid of nginx master process
> pid /usr/local/www/nginx.pid;
>
> # Number of worker connections. 1024 is a good default
> events {
>   worker_connections 1024;
> }
>
> # start the http module where we config http access.
> http {
>   # pull in mime-types. You can break out your config
>   # into as many include's as you want to make it cleaner
>   include /usr/local/nginx/conf/mime.types;
>
>   # set a default type for the rare situation that
>   # nothing matches from the mimie-type include
>   default_type  application/octet-stream;
>
>   # configure log format
>   log_format main '$remote_addr - $remote_user [$time_local] '
>                   '"$request" $status  $body_bytes_sent "$http_referer"
> '
>                   '"$http_user_agent" "$http_x_forwarded_for"';
>
>   # main access log
>   access_log  /usr/local/www/log/nginx_access.log  main;
>
>   # main error log
>   error_log  /usr/local/www/log/nginx_error.log debug;
>
>   # no sendfile on OSX
>   sendfile on;
>
>   # These are good default values.
>   tcp_nopush        on;
>   tcp_nodelay       off;
>   # output compression saves bandwidth
>   gzip            on;
>   gzip_http_version 1.0;
>   gzip_comp_level 2;
>   gzip_proxied any;
>   gzip_types      text/plain text/html text/css application/x-javascript
> text/xml application/xml application/xml+rss text/javascript;
>
>  server {
>
>     # port to listen on. Can also be set to an IP:PORT
>     listen *:8080;
>
>     # Set the max size for file uploads to 50Mb
>     client_max_body_size 50M;
>
>     # sets the domain[s] that this vhost server requests for
>     server_name .foo.com *;
>
>     # doc root
>     root /usr/local/www/test;
>
>     # vhost specific access log
>     access_log  /usr/local/www/log/nginx.vhost.access.log  main;
>
>     # this rewrites all the requests to the maintenance.html
>     # page if it exists in the doc root. This is for capistrano's
>     # disable web task
>     error_page   500 502 504  /500.html;
>     error_page   503 @503;
>     location @503 {
>       rewrite ^(.*)$ /system/maintenance.html break;
>     }
>     location /system/maintenance.html {
>       # pass
>     }
>
>     location / {
>       if (-f $document_root/system/maintenance.html) {
>         return 503;
>       }
>     }
>
>   }
>
> }
> ---------------------------
>
>
>

Here's my server block.  My ordering is slightly different.
http://pastie.caboo.se/private/dmnepj3m2zxsnxhrqsuhcq

Here's the shell output from curl before and after the maintenance
page goes up, and it appears to be delivering the content as expected.
 http://pastie.caboo.se/private/rpjtmssmf8jfyblhp4rpfq


-- 
Corey Donohoe
http://www.atmos.org/





More information about the nginx mailing list