如何在 Passenger suburi 部署上配置维护页面

发布于 2024-08-14 04:25:37 字数 173 浏览 7 评论 0原文

我正在尝试为 Rails 应用程序的 Phusion Passenger 上的 suburi 部署获取维护页面设置。所有文档都显示了 DocumentRoot ReWrite 规则,这些规则不会出现(不认为它们应该)在 suburis 上重写。我尝试修改重写规则来指向 suburi,但我似乎无法让它工作。有谁能够获得有效的设置吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

那一片橙海, 2024-08-21 04:25:37

我遇到了完全相同的问题。
虽然我使用的是before过滤方式,但我其实很讨厌这种方法。

如果我有几个子uri,更新并回答

这将起作用,这里唯一缺少的是我无法将标头设置为503,因为ErrorDocument依赖于一个静态文件,我无法确定它在运行时的位置。

假设 app1 和 app2 是我的子 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

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
梦回旧景 2024-08-21 04:25:37

所以我终于有一些时间来研究这个问题,发现你实际上可以使用 mod_rewrite 方法来处理维护页面,并进行一些调整。请记住,对于子域,在根目录中创建了一个指向应用程序公共目录的符号链接。现在,如果公共目录包含维护文件(或在子目录中),您可以连接 mod_rewrite 来查找它。

例如,假设应用程序名为 app1,并且 ma​​intenance.html 文件存储在 public 的子目录 system 中目录。以下是 apache 配置文件中的几行,它是在 RailsBaseURI /app1 行之前还是之后声明似乎并不重要

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/app1/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /app1/system/maintenance.html [L]

RailsBaseURI /app1

So I finally had some time to work on this and found that you can actually use the mod_rewrite method of handling maintenance page with some tweaks. Remember that for sub-domains there is a symbolic link created in the root directory to public directory of the application. Now if the public directory includes the maintenance file (or in a sub-directory) you can wire up mod_rewrite to find it.

For example assume application is named app1, and maintenance.html file is stored in a subdirectory system in the public directory. Here are the lines in the apache config file and it does not appear to matter whether it is declared before or after the RailsBaseURI /app1 line

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/app1/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /app1/system/maintenance.html [L]

RailsBaseURI /app1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文