How to create custom error 502 nginx in core of nginx (not using redirect to error page)? -


sometimes issue error 502 when httpd service down. in 1 minute website come back.

i need custom 502 message ask user wait 1 minute refresh page, or embed javascript or meta refresh tag auto refresh page after 1 minute. page's url must same make refresh effect

notice know custom error page redirect eg location = /502.html, type of custom error page redirect user other page, if refresh page got error page again.

any idea helpful.


edit update more detail 10/06/2012.

my nginx config:

user  nobody; # no need more workers in proxy mode worker_processes  24; error_log  /var/log/nginx/error.log crit; #worker_rlimit_nofile 20480; events {  worker_connections 109024; # increase busier servers  use epoll; # should use epoll here linux kernels 2.6.x }  http {  server_name_in_redirect off;  server_names_hash_max_size 2048;  server_names_hash_bucket_size 256;  include    mime.types;  default_type  application/octet-stream;  server_tokens off;  sendfile on;  tcp_nopush on;  tcp_nodelay on;  keepalive_timeout  20;   ignore_invalid_headers on;  client_header_timeout  50m;  client_body_timeout 50m;  send_timeout     20m;  reset_timedout_connection on;  connection_pool_size  2048;  client_header_buffer_size 256k;  large_client_header_buffers 4 256k;  client_max_body_size 20m;   client_body_buffer_size 300k;  request_pool_size  32k;  output_buffers  14 32k;  postpone_output  1460;  proxy_temp_path  /tmp/nginx_proxy/;  proxy_cache_path /dev/shm/nginx levels=1:2 keys_zone=wwwcache:45m inactive=5m max_size=1000m;  client_body_in_file_only off;  access_log off;  open_log_file_cache off;  #log_format bytes_log "$msec $bytes_sent .";  include "/etc/nginx/vhosts/*"; } 

and vhost config:

server {  #         error_log /var/log/nginx/vhost-error_log warn;           listen 123.30.137.66:80;           server_name xaluan.net mtvvui.com www.daiduong.com.au www.xaluan.net xaluan.com www.xaluan.com www.daiduongrestaurant.net veryzoo.com www.mtvvui.com www.xaluan.org www.veryzoo.com daiduongrestaurant.net xaluan.org daiduong.com.au; #          access_log /usr/local/apache/domlogs/xaluan.net combined;           root /home/xaluano/public_html;           location / {       if ($http_cache_control ~ "max-age=0") {                 set $bypass 1;           }        location  ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$  {       #root /home/xaluano/public_html;       #proxy_cache wwwcache;       #proxy_cache_valid  200 15m;       #proxy_cache_bypass $bypass;           expires 1d;           #try_files $uri @backend;       proxy_pass http://123.30.137.66:8081;           }           error_page 405 = @backend;           add_header x-cache "hit backend";       #proxy_set_header server "caching-proxy";           #add_header x-cache-vinahost "hit backend";       proxy_pass http://123.30.137.66:8081;           include proxy.inc;            }             location @backend {           internal;           proxy_pass http://123.30.137.66:8081;           include proxy.inc;           }           location ~ .*\.(php|jsp|cgi|pl|py)?$ {           #proxy_cache wwwcache;       #proxy_cache_valid  200 15m;        proxy_pass http://123.30.137.66:8081;           include proxy.inc;           }           location ~ /\.ht {           deny all;           }       } 

== the case test..

if apache httpd service stops: #service httpd stop

then open in browser link: http://www.xaluan.com/modules.php?name=news&file=article&sid=123456 see 502 error same url on browser address.

== custom error page need config when apache fail, show custom message telling user wait 1 minute service back, refresh current page same url (refresh can easy javascript), nginx not change url javascript can work out.

aright found answer.. in vhost config file.. put right @ end of server {} before closing }

 error_page 502 /502.html;  location = /502.html {        root  /home/xaluano/public_html;    } 

of cause need create file 502.html @ domain root, meta-tag refresh, , java-script auto refresh. content of html page following

<head> <meta http-equiv="refresh" content="40" />  </head> <body> <script language="javascript" type="text/javascript"> /*<![cdata[*/ var timerval = 40; var timerspan = document.getelementbyid("cdtimer"); function countdown(){    settimeout( "countdown()", 1000 );    timerspan.innerhtml=timerval;    timerval=timerval-1;    if (timerval<0) { timerval=0;    location.reload(true);  //   window.location.href = "http://www.xaluan.com";    } //improvement vivalibre, tq  } countdown(); /*]]>*/ </script>  </body> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -