# Maintenance Page

**URL:** <https://www.ruby-forum.com/t/maintenance-page/218415>\
**Category:** NGINX\
**Created:** [March 30, 2012, 8:54pm UTC](https://www.ruby-forum.com/t/maintenance-page/218415 "2012-03-30T20:54:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 30, 2012, 8:54pm UTC](https://www.ruby-forum.com/t/maintenance-page/218415/1 "2012-03-30T20:54:26Z")

</div>

Dear List,

I am looking for a maintenance page while working on the upstream Tomcat  
server. Below is my nginx.conf file. Is there anything wrong in this  
config  
, as it’s not redirecting to the maintenance.html page.

#######################################################################

# This is the main Nginx configuration file.

#######################################################################  
user www-server;  
pid logs/nginx.pid;  
worker\_processes 8;

error\_log /usr/local/nginx/logs/error.log;  
#----------------------------------------------------------------------

# Events Module

#----------------------------------------------------------------------  
events {  
worker\_connections 1024;  
}  
#----------------------------------------------------------------------

# HTTP Core Module

#----------------------------------------------------------------------  
http {  
include /usr/local/nginx/conf/mime.types;  
default\_type application/octet-stream;

```
log_format main '$remote_addr - $remote_user [$time_local] 

```

“$request”  
’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘"$http\_user\_agent" “$http\_x\_forwarded\_for”’;

```
access_log /usr/local/nginx/logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
    upstream backend {
    # ip_hash;
        server 192.168.65.102:8080 srun_id=a;
        #server 192.168.65.103:8080;
        jvm_route $cookie_JSESSIONID reverse;
    }
server {
    listen 80;
    server_name report-int.example.com;
    root /var/www/example.com/;

    location / {
            if (-f $document_root/maintenance.html) {
            return 503;
      }
        proxy_pass http://backend;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
client\_max\_body\_size 10m;  
client\_body\_buffer\_size 128k;  
proxy\_connect\_timeout 90;  
proxy\_send\_timeout 90;  
proxy\_read\_timeout 90;  
proxy\_buffer\_size 4k;  
proxy\_buffers 4 32k;  
proxy\_busy\_buffers\_size 64k;  
proxy\_temp\_file\_write\_size 64k;  
}  
error\_page 503 @maintenance;  
location @maintenance {  
rewrite ^(.\*)$ /maintenance.html break;  
}  
error\_page 404 /404.html;  
location = /404.html {  
root /usr/local/nginx/html;  
}  
# redirect server error pages to the static page /50x.html  
#  
error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /usr/local/nginx/html;  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![trm\_asn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@trm\_asn](https://www.ruby-forum.com/u/trm_asn)\
**Post date:** [March 30, 2012, 9:39pm UTC](https://www.ruby-forum.com/t/maintenance-page/218415/2 "2012-03-30T21:39:20Z")

</div>

On Sat, Mar 31, 2012 at 12:23:43AM +0530, trm asn wrote:

Hi there,

> I am looking for a maintenance page while working on the upstream Tomcat  
> server. Below is my nginx.conf file. Is there anything wrong in this config  
> , as it’s not redirecting to the maintenance.html page.

This config seems to work for me.

When the appropriate maintenance.html is present, a request for  
/echo/foo  
returns 503 and the maintenance content; otherwise, the request returns  
the upstream response for /echo/foo.

What responses do you get from

curl -i [http://report-int.example.com/echo/foo](http://report-int.example.com/echo/foo)

when /var/www/example.com/maintenance.html is present, and is not  
present?

(And is there anything unusual in the output of “nginx -V” and “nginx  
-v”?)

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
