简体   繁体   中英

nginx custom error page css not applying

new to nginx and I'm trying to setup a custom maintenance page using a 503 code. I can get the page to display, but I'm missing something and the css isn't being applied. When I look at it as conventional webpage, it works. What am I missing? Configs as follows:

nginx.conf

user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log info;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server_names_hash_bucket_size  128;

    # Set the max size for file uploads to 50Mb
    client_max_body_size 50M;

    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    #sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;
    underscores_in_headers on;
    include /etc/nginx/conf.d/*.conf;
}

blah.conf

server {
        listen      80;

        root    /var/www/blah-maintenance;
        error_page 503 /503.html;

        location / {
                return 503;
        }

        location /503.html {
                internal;
        }

}

503.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8">
  <link rel="stylesheet" type="text/css" href="/maint.css" />
 </head>
<body>

        <div class="container">

                <h1>SYSTEM IS CURRENTLY UNDERGOING MAINTENANCE</h1>

                <p class="blah">blah and blah-blah currently undergoing <b><u><font color="red">maintenance</font></u></b>.

                <P class="blah">The system/s will be available as soon as possible. Please check back later.

                <p class="blah">Thanks - 

        </div>

</body>

maint.css

/* CSS Document*/
/*Define the body element's color*/

body {
        background: white url(black-floor-blah-wallpaper.jpg) no-repeat;
        background-postion: center center;
}

h1 {
        text-align:center;
        font-size: 32pt;
        color: White;
        font-family: Helvetica, Geneva, Arial,
        SunSans-Regular, sans-serif
}

/*This section is for links*/

a:link {
        font-weight:normal;
        color:Red
}

a:visited {
        font-weight:normal;
        color:Silver;
}

a:hover {
        font-weight:bold;
        color: White;
        font-variant:small-caps;
}

/*This section is for a paragraph section*/

div.container {
                display: tabel-cell;
                vertical-align: middle;
                postion: absolute;
                top: 50%;
                width: 100%;
}

p.blah {
        text-align:center;
        font-style:italic;
        font-size:18px;
        color: White;
}

blue {
        color:#0000FF;
}

/*This section is for the image's black border.*/

img {
        border-color: #000000;
        border:thick;
        border-style:ridge;`enter code here`
}

It's possible the browser's request to maint.css is being intercepted by nginx and responded to with a maintenance page. You can verify this by pulling up WebKit Inspector, Firebug, or similar and reviewing the traffic on the Network tab. The response for /maint.css should return CSS content. If it's being intercepted, you'll see your maintenance page instead.

I usually inline styles and assets for maintenance pages, or redirect the entire request to a different, non-maintenance zone for delivery of the static assets. You could also write redirection rules for /maint.css, but that can proliferate pretty quickly. ("Oh wait, we also need these images. Oh, we also need these scripts...")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM