【问题标题】:nginx custom maintenance 503 pagenginx自定义维护503页面
【发布时间】:2014-02-23 11:21:53
【问题描述】:

我有一个带有自定义 503 的 nginx。

error_page 503 @maintenance;

location @maintenance {
    root   /usr/share/nginx/html/custom/503;
    rewrite ^(.*)$ /index.html break;
}

location  /503-static/ {
    root /usr/share/nginx/html/custom/;
}

我的 /503/index.html 是我的自定义维护页面,其中包含漂亮的 CSS 和照片:

<link rel="stylesheet" type="text/css" href="https://www.mydomain.tld/503-static/maintenance.css">

所有这些都工作正常。

问题是我想用 503-static/maintenance.css 之类的相对链接替换 ​​css 链接。

如果用户请求:www.mydomain.tld 自定义 html 将被加载,并且带有相对路径的 maintenance.css 也会被加载

但是:如果用户请求:www.mydomain.tld/a/b/c/bla.html,我的自定义 503 索引 html 将被正常加载,但 css 的相对链接将是 $document_root/a/b /c/503-static/maintenance.css ....不会显示

我的问题是:使用 css 文件的相对链接路径...如何应对不同的 $uri?重写有什么帮助吗?

谢谢

【问题讨论】:

    标签: nginx rewrite maintenance http-status-code-503


    【解决方案1】:

    只需剥离协议和域,保留前导斜杠。相对路径非常不适合这种情况。绝对完美的工作。

    【讨论】:

      猜你喜欢
      • 2011-02-02
      • 2012-07-07
      • 2022-10-05
      • 2011-06-07
      • 2014-05-14
      • 2010-11-04
      • 1970-01-01
      • 2011-06-27
      • 2013-02-27
      相关资源
      最近更新 更多