403禁止在nginx +乘客+ sinatra

我查看了大量的帖子,但我无法超越这个403 Forbidden错误。 我有:

  • 更新了网站文件夹中的nginx用户权限
  • 更新passenger_ruby以使用RVM包装目录
  • 使用passenger-config --root确认passenger_root路径
  • 我仍然得到403,似乎无法找到我想念的东西。

    以下是我的文件。

    文件夹结构 (755 www-data):

    --website
    ----app
    ----public
    ----tmp
    ----views
    ----config.ru
    

    config.ru

    require 'rubygems'
    require 'sinatra'
    
    set :environment, ENV['RACK_ENV'].to_sym
    disable :run, :reload
    
    require File.expand_path '../app/main.rb', __FILE__
    
    run Sinatra::Application
    

    Server .conf

    server {
      listen 80;
      server_name website.com;
    
      root /www/website/public;   # <--- be sure to point to 'public'!
      passenger_enabled on;
    }
    

    Nginx的.conf

    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
    passenger_ruby /usr/local/rvm/wrappers/ruby-2.2.1/ruby;
    

    示例main.rb

     Require 'slim'
     get "/"
         slim: index
     do
    

    网站错误日志:

    2015/07/28 19:09:45 [error] 34000#0: *2 directory index of "/www/website/public/" is forbidden, client: 0.0.0.0, server: website.com, request: "GET / HTTP/1.1", host: "website.com"
    

    尝试以下方法:https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04

    如果您已经配置了乘客,只需跳过该步骤并使用nginx配置即可。


    我刚刚开始使用Ruby | Sinatra | Passenger | Nginx和我有同样的模糊问题。

    围绕以下配置进行了大量的黑客工作后为我工作。 这可能并不完美,但我希望它能帮助别人解决这个问题。

    文件夹结构(755 www-data):

    --sinatra_test
    ----public #added this blank dir
    ----tmp    #added this blank dir
    ----config.ru
    ----SinatraTest.rb
    

    config.ru:

    require File.absolute_path("SinatraTest.rb")
    run SinatraTest
    

    SinatraTest.rb:

    require 'sinatra/base'
    
    class SinatraTest < Sinatra::Base
        get '/' do
          "Hello World"
        end
    end
    

    Nginx的.conf:

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    
    events {
            worker_connections 768;
            # multi_accept on;
    }
    
    http {
    
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            types_hash_max_size 2048;
            # server_tokens off;
    
            # server_names_hash_bucket_size 64;
            # server_name_in_redirect off;
    
            include /etc/nginx/mime.types;
            default_type application/octet-stream;
    
            ##
            # SSL Settings
            ##
    
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
            ssl_prefer_server_ciphers on;
    
            ##
            # Logging Settings
            ##
    
            access_log /var/log/nginx/access.log;
            error_log /var/log/nginx/error.log;
    
            gzip on;
            gzip_disable "msie6";
    
            passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
            passenger_ruby /home/myusername/.rvm/gems/ruby-2.4.0/wrappers/ruby;
    
            server {
                    listen 80;
                    server_name myservername.com;
    
                    # Tell Nginx and Passenger where your app's 'public' directory is
                    root /home/myusername/sinatra_test/public;
    
                    passenger_enabled on;
            }
    }
    
    链接地址: http://www.djcxy.com/p/32409.html

    上一篇: 403 Forbidden on nginx + passenger + sinatra

    下一篇: ruby on rails nginx with passenger can't find views