本文介绍了403禁止在使用Nginx + Rails + Passenger时使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试访问在Nginx和passenger之上运行的rails应用程序时,我得到了403.这是日志文件中的错误:

I am getting a 403 when I try to access my rails app running on top of nginx and passenger. Here is the error from the log file:

2013/05/09 13:52:34 [error] 27787#0: *1 directory index of "/var/www/Tread-Forth/current/public/" is forbidden, client: 192.249.16.60, server: treadforth.com, request: "GET / \
HTTP/1.1", host: "www.treadforth.com"

即使我以root身份运行nginx,也会出现此问题,因此我认为这不是权限问题.我认为问题是我的nginx.conf文件中没有定义passenger_rubypassenger_root.问题是,我不知道这些值在配置文件中的位置,也不知道它们的值应该是什么.任何帮助将是巨大的.这是我的conf文件供参考:

This problem occurs even when I run nginx as root, so I don't think it is a permissions problem. I think the problem is that I do not have passenger_ruby or passenger_root defined in my nginx.conf file. The problem is, I don't know where these values go in the config file, and I don't know what their values should be. Any help would be great. Here is my conf file for reference:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    #passenger_root /usr/local/bin/passenger;
    #passenger_ruby /usr/local/bin/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  .treadforth.com;
        root /var/www/Tread-Forth/current/public;
        passenger_enabled on;
    }
}

您可以看到我尝试过的注释掉的passenger_root和passenger_ruby版本.当我取消注释时,nginx无法启动,但不会产生任何错误消息.

You can see the commented out version of passenger_root and passenger_ruby I have tried. When I uncomment these, nginx fails to start but does not produce any error messages.

推荐答案

您可以使用passenger-config --root检查乘客安装的路径,并使用which ruby检查红宝石安装的路径.

You can check the path of your passenger installation with passenger-config --root, and the path of your ruby installation with which ruby.

这篇关于403禁止在使用Nginx + Rails + Passenger时使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 11:31