首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx自定义错误页面css不适用

nginx自定义错误页面css不适用
EN

Stack Overflow用户
提问于 2014-02-19 02:44:01
回答 1查看 1.3K关注 0票数 0

nginx新手,我正在尝试使用503代码设置一个自定义维护页面。我可以让页面显示,但是我遗漏了一些东西,并且没有应用css。当我把它看作是传统的网页时,它是有效的。我遗漏了什么?配置如下:

nginx.conf

代码语言:javascript
复制
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

代码语言:javascript
复制
server {
        listen      80;

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

        location / {
                return 503;
        }

        location /503.html {
                internal;
        }

}

503.html

代码语言:javascript
复制
<!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

代码语言:javascript
复制
/* 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`
}
EN

回答 1

Stack Overflow用户

发布于 2014-02-19 05:23:42

浏览器对maint.css的请求可能会被nginx拦截,并通过维护页面进行响应。您可以通过启动WebKit检查器、Firebug或类似工具并查看网络选项卡上的流量来验证这一点。/maint.css的响应应该返回CSS内容。如果它被拦截了,你会看到你的维护页面。

我通常内联维护页面的样式和资产,或者将整个请求重定向到不同的非维护区域,以交付静态资产。您也可以为/maint.css编写重定向规则,但它可能很快就会扩散开来。(“哦,等等,我们还需要这些图像。哦,我们还需要这些脚本...”)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21862659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档