Search code examples
url-rewritingpassengerphusion

How to configure maintenance pages on Passenger suburi deployments


I am trying to get a maintenance page setup for a suburi deployment on Phusion Passenger for a rails app. All the documentation shows DocumentRoot ReWrite rules, which don't appear (don't think they should) rewrite on suburis. I tried hacking around on the ReWrite rules to point at the suburi, but I can't seem to get it to work. Has anyone been able to get a setup which works?


Solution

  • I am having exactly the same problem. Although I am using the before filter way, I actually hate this method.

    update and answer

    this will work if I have several sub-uris, the only missing thing here is that I can not set the header to 503, because ErrorDocument is rely on a static file which I can not determine where it is in runtime.

    assume app1 and app2 is one of my sub-uri

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
    RewriteCond %{DOCUMENT_ROOT}/$1/system/maintenance.html -f
    RewriteCond %{SCRIPT_FILENAME} !maintenance.html
    RewriteRule ^/([^/]+)(/|/.*)?$ /$1/system/maintenance.html [L]
    
    RailsBaseURI /app1
    RailsBaseURI /app2