【问题标题】:Getting a 503 for the resources as well while setting up for a maintenance page in NGINXGetting a 503 for the resources as well while setting up for a maintenance page in NGINX
【发布时间】:2022-12-27 20:33:25
【问题描述】:

I'm trying to set up a maintenance page for an application, hosted via NGINX web server.

Currently I have this set up.

    location ^~/maintenance/ {
       root /path/to/the/maintenance/maintenance.html;
    }
set $maintenance 0;
if (-f /path/to/the/maintenance/maintenance.enable) {
   set $maintenance 1;
}
if ($maintenance = 1) {   
root /path/to/the/maintenance/maintenance.html
rewrite ^/(.*) /maintenance/maintenance.html break;
}

I have explicit CSS file in maintenance/CSS and images in maintenance/CSS

The behaviour with this set up is the case file is also getting rendered as the HTML doc and images are also not accessible when maintenance.enable file is present.

【问题讨论】:

  • Hi Emir. Excuse me for that, but it is unclear for me. What you're trying to achieve is that if maintenance.enable exists, redirect each request to maintenance.html, is it ?
  • Hi Philippe, Yes I'm trying to have an explicit maintenance mode setup without having to edit the config for the maintenance mode. If the maintenance.enable file is present I'm redirecting the requests.

标签: nginx nginx-config maintenance-plan


【解决方案1】:

This worked out when I moved the location block to the bottom of the logic(if Statements).

Since there was no issue in the syntax or anything, but nginx was trying to see the location once the conditions were met, but it did not find a location to work on. Correct me if I'm wrong as I'm new to nginx, I would love to get some insights of this scenario.

【讨论】:

    猜你喜欢
    • 2019-11-26
    • 2023-02-26
    • 2022-12-27
    • 2016-04-14
    • 2015-09-26
    • 2022-12-27
    • 2022-12-02
    • 2023-04-05
    • 2022-12-01
    相关资源
    最近更新 更多