| From | Sent On | Attachments |
|---|---|---|
| Douglas A. Seifert | Feb 2, 2008 3:18 pm | |
| Maxim Dounin | Feb 2, 2008 4:36 pm | |
| Douglas A. Seifert | Feb 2, 2008 5:08 pm | |
| Maxim Dounin | Feb 2, 2008 5:20 pm | |
| Eden Li | Feb 2, 2008 5:22 pm | |
| Douglas A. Seifert | Feb 2, 2008 6:14 pm | |
| Douglas A. Seifert | Feb 2, 2008 6:15 pm | |
| Maxim Dounin | Feb 2, 2008 6:33 pm | |
| Eden Li | Feb 2, 2008 6:47 pm | |
| Maxim Dounin | Feb 2, 2008 7:15 pm | |
| Douglas A. Seifert | Feb 2, 2008 8:02 pm | |
| Corey Donohoe | Feb 2, 2008 10:39 pm | |
| Igor Sysoev | Feb 2, 2008 10:40 pm | |
| Douglas A. Seifert | Feb 3, 2008 7:51 am | |
| Douglas A. Seifert | Feb 3, 2008 7:58 am | |
| Corey Donohoe | Feb 3, 2008 9:59 am | |
| Doug Seifert | Feb 3, 2008 1:36 pm | |
| Killian Murphy | Jun 19, 2009 9:47 pm | |
| Spirit Spirit | Nov 26, 2009 2:31 pm | |
| Igor Sysoev | Nov 26, 2009 10:02 pm | |
| spirit | Dec 2, 2009 1:46 pm |
| Subject: | Re: Custom 503 Error Page | |
|---|---|---|
| From: | Eden Li (eden...@public.gmane.org) | |
| Date: | Feb 2, 2008 5:22:44 pm | |
| List: | ru.sysoev.nginx | |
Try:
if (-f $document_root/system/maintenance.html) { rewrite ^(.*)$ @maintenance last; }
location = @maintenance { error_page 503 /system/maintenance.html; return 503; }
On Feb 3, 2008, at 7:18 AM, Douglas A. Seifert wrote:
I am trying to use a test for the existence of a file to return a error page with a 503 Temporarily Unavailable response code. My configuration is below. The problem is that it does not work. I can see the custom error page, but the HTTP status code is 200, not the desired 503.
If I change the if directive to this:
if (-f $document_root/system/maintenance.html) { rewrite ^(.*)$ /system/maintenance.html; # No last return 503; }
I start getting a 503 HTTP status code, but the content is not my custom error page, but rather the default 503 response compiled into the nginx server.
Am I doing something terribly wrong? I would really like to see my custom page with a real 503 HTTP status code.
Thanks for any help, Douglas A. Seifert
nginx.conf:
-------------------------------------------------- # user and group to run as #user www www;
# 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 if (-f $document_root/system/maintenance.html) { rewrite ^(.*)$ /system/maintenance.html last; return 503; }
location / { root /usr/local/www/test; }
error_page 500 502 504 /500.html; error_page 503 /503.html; }
}
-----------------------------------------------------------------





