【问题标题】:Ruby+Sinatra+nginx=403 ForbiddenRuby+Sinatra+nginx=403 禁止
【发布时间】:2015-10-30 21:26:48
【问题描述】:

我已经安装了 ruby​​+nginx server+sinatra,但目前我遇到了 403 禁止错误。日志说:

2015/08/07 15:03:07 [error] 2902#0: *4 directory index of "/home/ruby-deployer/sin-app/hello/" is forbidden, client: ::1, server: 172.17.0.252, request: "GET / HTTP/1.0", host: "localhost"

我的虚拟主机配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name 172.17.0.252;
    passenger_enabled on;
    rails_env    production;
    root          /home/ruby-deployer/sin-app/hello;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

nginx.conf:

 ##
    # Phusion Passenger config
    ##
    # Uncomment it if you installed passenger or passenger-enterprise
    ##

    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
    passenger_ruby /home/ruby-deployer/.rvm/gems/ruby-2.2.2/wrappers/ruby;

你好/app.rb:

require 'sinatra'
get '/' do
'Hello world!'
end

你好/config.ru:

require 'rubygems'
require 'sinatra'
require './app.rb'
run Sinatra::Application

我做错了什么?

【问题讨论】:

  • 我想说这个问题应该属于serverfault
  • 首先在 nginx 中添加第一行用户 your_username,如果它不起作用 chmod 应用程序所在的文件夹
  • chmod 777 - 这是我检查的第一件事

标签: ruby nginx sinatra passenger


【解决方案1】:

转到您的 nginx 配置文件,并添加 user your_user_name; 作为第一行更新:保存并重新启动服务器。

如果这不起作用,请使用 /home/ruby-deployer/sin-app/hello 提供更多访问权限

chmod 755 /home/ruby-deployer/sin-app/hello

【讨论】:

  • 感谢您的回答。但这无济于事:(
  • 重启后看到同样的图片:403 Forbidden nginx/1.8.0
  • 试试 chmod 755 home/ruby-deployer/sin-app 如果还是不行,试试 chmod 755 home/ruby-deployer/
猜你喜欢
  • 2015-10-19
  • 2019-06-07
  • 2019-04-17
  • 2019-05-29
  • 1970-01-01
  • 2019-01-28
  • 2016-04-24
  • 2019-01-23
相关资源
最近更新 更多