开发者

Maintenance page with nginx for one domain_name among others

I have a rail app that serves multiple domain_name and is deployed by nginx & passenger. I need to put one domai开发者_JAVA技巧n under maintenance mode while the other still work as usual. Here is my config:

server {
    listen 80;
    server_name domain1.com domain2.com domain3.com domain4.com;
    error_page 503 http://$host/maintenance.html;

    location /maintenance.html {
      # Allow requests
    }

    location / {
        root /var/www/myapp/public;   # <--- be sure to point to 'public'!
        error_page 503 http://$host/maintenance.html;
        passenger_enabled on;
        rails_env development;
        passenger_use_global_queue on;

        if (-f /var/www/myapp/public/maintenance.html) {
            return 503;
        }
    }
}

The above config would cause all domains under maintenance. However, I want to put domain1.com is under maintenance mode. How would I achieve this?


you can add another server entry for server "domain1.com" which serve request for this domain only. like:

server {
listen 80;
server_name domain1.com 
error_page 503 http://$host/maintenance.html;
root /your/root/directory/
if (-f $document_root/maintenance.html){
    rewrite  ^(.*)$  /maintenance.html last;
     break;
      }

location /maintenance.html {
  # Allow requests
}}

you need to ensure following

  1. The "domain1.com" should be removed from previous server entry
  2. maintenance.html page should be present in /your/root/directory/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜