403 Forbidden when using nginx + rails + passenger

杀马特。学长 韩版系。学妹 提交于 2019-12-11 06:44:05

问题


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"

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;
    }
}

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.


回答1:


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




回答2:


To find path for passenger_root:
$ passenger-config --root

To find path for passenger_ruby, run the below and you see passenger_ruby path
$ passenger-config --ruby-command




回答3:


Forbidden means that you have a permission problem. Check your directory and file permissions so that they are readable by your webserver.



来源:https://stackoverflow.com/questions/16473586/403-forbidden-when-using-nginx-rails-passenger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!