【问题标题】:Setting root path to rails app's root_path in nginx在 nginx 中将根路径设置为 rails 应用程序的 root_path
【发布时间】:2016-08-02 19:40:08
【问题描述】:

我已经使用passenger、nginx 和capistrano 在Digital Ocean (DO) 上配置了一个rails 应用程序。一切正常,希望每当我访问网站时都能显示应用程序的 root_path 页面。但事实并非如此。我必须在公共目录中保留另一个页面 index.html 并将其设置为 root,例如:

xyz.conf 文件

root /home/user/apps/xyz/current/public;

我不希望显示这个额外的静态页面。只是看起来不太好。相反,我希望显示我在 routes.rb 文件中指定的应用程序的根页面,例如 root 'controller#method'

我尝试在 .conf 文件中删除根行或将其限制为 /home/user/apps/xyz/current ,但这只会给出 403 Forbidden 错误,应该是这种情况。

我想了很多,但什么都想不出来。有没有人遇到过类似的问题并设法解决了?

【问题讨论】:

    标签: ruby-on-rails-4 nginx passenger digital-ocean


    【解决方案1】:

    你的 nginx root 必须是这样的:

    root /home/rails/sample_tasks/public;
    

    注意:路径可能会有所不同,但您需要将路径设置为应用的公共文件夹

    然后重新加载你的 Nginx

    service nginx reload 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 2011-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多