2014-02-18 62 views
0

新的nginx和我试图建立一个自定义维护页面使用503代码。我可以让页面显示,但我错过了一些东西,而且CSS没有被应用。当我把它看作传统的网页时,它就起作用了。我错过了什么? CONFIGS如下:nginx自定义错误页面的CSS不应用

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` 
} 

回答

0

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

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

相关问题