新铁轨 +乘客部署工作一半......不知道为什么?

发布于 2024-09-06 06:48:06 字数 2598 浏览 6 评论 0原文

我正处于整个 Rails 周期往返的最后阶段:开发 -> 开发测试->生产(在外部服务器上)。我已经非常接近了...但是在生产版本中看到了一些错误,并且对 Rails 的“魔力”了解不够,无法对其进行故障排除...

这有效:www.mydomain.com/rails 并返回我的应用程序的视图

,但是: www.mydomain.com/rails/ 返回(完整):

<html>
<body>
Index from public
</body>
</html>

这是从哪里来的!?!我已经排除了阿帕奇。因为 Apache 不会返回那种 html 作为目录索引...

添加: VirtualHost(每个请求):

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAdmin [email protected]
    DocumentRoot "/Library/WebServer/mydomainweb"
    DirectoryIndex "index.html" "index.php"
    CustomLog "/var/log/apache2/access_log" "%h %l %u %t \"%r\" %>s %b"
    ErrorLog "/var/log/apache2/error_log"
    ErrorDocument 404 /error.html
    <IfModule mod_ssl.c>
        SSLEngine Off
        SSLCertificateFile "/etc/certificates/Default.crt"
        SSLCertificateKeyFile "/etc/certificates/Default.key"
        SSLCipherSuite "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:!SSLv2:+EXP:+eNULL"
    </IfModule>
    <IfModule mod_dav.c>
        DAVLockDB "/var/run/davlocks/.davlock100"
        DAVMinTimeout 600
    </IfModule>
    <IfModule mod_mem_cache.c>
        CacheEnable mem /
        MCacheSize 4096
    </IfModule>
    <Directory "/Library/WebServer/mydomainweb">
        AllowOverride None
        <IfModule mod_dav.c>
            DAV On
        </IfModule>
        Options All -Includes -ExecCGI +MultiViews -Indexes
    </Directory>
    RailsBaseURI /rails
    <Directory /Library/WebServer/rails/myapp/public>
        Options -MultiViews -Indexes
    </Directory>
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^TRACE
        RewriteRule .* - [F]
    </IfModule>
    <IfModule mod_proxy_balancer.c>
        <Proxy "balancer://balancer-group">
        </Proxy>
    </IfModule>
    <IfModule mod_alias.c>
        Alias "/collaboration" "/usr/share/collaboration"
        Alias "/icons/" "/usr/share/httpd/icons/"
        Alias "/error/" "/usr/share/httpd/error/"
        Redirect temp "/zapp.html" "/index.html"
    </IfModule>
    Include /etc/apache2/httpd_groups.conf
    Include /etc/apache2/httpd_teams_required.conf
    LogLevel warn
    ServerAlias mydomain.com
    ServerAlias images.mydomain.com
</VirtualHost>

I'm in the final stages of going round trip through the entire Rails cycle: development -> test -> production (on an external server). I'm very close...but seeing some errors with the production version and don't know enough about Rails' "magic" to troubleshoot it yet...

this works: www.mydomain.com/rails and returns my app's view

but this: www.mydomain.com/rails/ returns (in its entirety):

<html>
<body>
Index from public
</body>
</html>

Where is this coming from!?! I've ruled out Apache. as Apache wouldn't return that kind of html as an index of a directory...

Added: VirtualHost (per request):

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAdmin [email protected]
    DocumentRoot "/Library/WebServer/mydomainweb"
    DirectoryIndex "index.html" "index.php"
    CustomLog "/var/log/apache2/access_log" "%h %l %u %t \"%r\" %>s %b"
    ErrorLog "/var/log/apache2/error_log"
    ErrorDocument 404 /error.html
    <IfModule mod_ssl.c>
        SSLEngine Off
        SSLCertificateFile "/etc/certificates/Default.crt"
        SSLCertificateKeyFile "/etc/certificates/Default.key"
        SSLCipherSuite "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:!SSLv2:+EXP:+eNULL"
    </IfModule>
    <IfModule mod_dav.c>
        DAVLockDB "/var/run/davlocks/.davlock100"
        DAVMinTimeout 600
    </IfModule>
    <IfModule mod_mem_cache.c>
        CacheEnable mem /
        MCacheSize 4096
    </IfModule>
    <Directory "/Library/WebServer/mydomainweb">
        AllowOverride None
        <IfModule mod_dav.c>
            DAV On
        </IfModule>
        Options All -Includes -ExecCGI +MultiViews -Indexes
    </Directory>
    RailsBaseURI /rails
    <Directory /Library/WebServer/rails/myapp/public>
        Options -MultiViews -Indexes
    </Directory>
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^TRACE
        RewriteRule .* - [F]
    </IfModule>
    <IfModule mod_proxy_balancer.c>
        <Proxy "balancer://balancer-group">
        </Proxy>
    </IfModule>
    <IfModule mod_alias.c>
        Alias "/collaboration" "/usr/share/collaboration"
        Alias "/icons/" "/usr/share/httpd/icons/"
        Alias "/error/" "/usr/share/httpd/error/"
        Redirect temp "/zapp.html" "/index.html"
    </IfModule>
    Include /etc/apache2/httpd_groups.conf
    Include /etc/apache2/httpd_teams_required.conf
    LogLevel warn
    ServerAlias mydomain.com
    ServerAlias images.mydomain.com
</VirtualHost>

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

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

发布评论

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

评论(2

风吹过旳痕迹 2024-09-13 06:48:06

我的猜测是,apache 启用了目录浏览,并且乘客正在将此请求路由到公共文件夹,而公共文件夹又将直接发送到 apache。

您可以尝试

  1. 通过禁用选项索引(省略索引)来禁用目录浏览。
  2. 您可能会在routes.rb 文件中明确捕获到该路径的路由,并将其路由到您希望的位置。

My guess is that apache has directory browsing enabled and passenger is routing this request to the public folder which in turn is going to apache direct.

You can try

  1. Disabling directory browsing by disabling Options Indexes (omitting Indexes)
  2. You possibly catch a route in your routes.rb file to that path explicitly and route it to where you wish.
依 靠 2024-09-13 06:48:06

对于第二个,如果您执行 www.mydomain.com/rails/mycontroller/show/1 是否有效?

如果它与 mycontroller 和 1 之间的“show”一起工作,则您的路线有问题。

For the second one, does it work if you do www.mydomain.com/rails/mycontroller/show/1?

If it works with "show" in between mycontroller and 1, there's a problem with your routes.

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