在 Sinatra 和 Unicorn 和 Nginx 上总是请求成为未找到的方法
Always request becomes not found method on Sinatra and Unicorn and Nginx
要部署在Sinatra和Unicorn和nginx中,当你访问合适的URL时,总是会请求变成"not_found do"方法。
(例如:hogehoge.com/test/)
但是,当我在本地测试后,它会正确地进入"get '/' do"方法。
你觉得哪里有问题?
请告诉我。
[test.rb]
# coding: utf-8
require "sinatra"
require 'unicorn'
class Main < Sinatra::Application
get '/' do
'Success'
end
not_found do
'not_found'
end
end
[config.ru]
require './test'
run Main
[unicorn.rb]
@dir = "/var/www/Test"
worker_processes 2
working_directory @dir
preload_app true
timeout 30
listen "#{@dir}/tmp/test.sock", :backlog => 64
pid "#{@dir}/tmp/pids/unicorn.pid"
stderr_path "#{@dir}/log/unicorn.stderr.log"
stdout_path "#{@dir}/log/unicorn.stdout.log"
[nginx.conf]
location /test {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://Test;
}
upstream Test {
server unix:/var/www/Test/tmp/test.sock;
}
不同的 nginx 路径和 rb 路径
(For Example: hogehoge.com/test/)
[test.rb]
# coding: utf-8
require "sinatra"
require 'unicorn'
class Main < Sinatra::Application
get '/' do
'Success'
end
get '/test' do
'test Success'
end
not_found do
'not_found'
end
end
添加
get '/test' do
'test Success'
end
要部署在Sinatra和Unicorn和nginx中,当你访问合适的URL时,总是会请求变成"not_found do"方法。
(例如:hogehoge.com/test/)
但是,当我在本地测试后,它会正确地进入"get '/' do"方法。
你觉得哪里有问题?
请告诉我。
[test.rb]
# coding: utf-8
require "sinatra"
require 'unicorn'
class Main < Sinatra::Application
get '/' do
'Success'
end
not_found do
'not_found'
end
end
[config.ru]
require './test'
run Main
[unicorn.rb]
@dir = "/var/www/Test"
worker_processes 2
working_directory @dir
preload_app true
timeout 30
listen "#{@dir}/tmp/test.sock", :backlog => 64
pid "#{@dir}/tmp/pids/unicorn.pid"
stderr_path "#{@dir}/log/unicorn.stderr.log"
stdout_path "#{@dir}/log/unicorn.stdout.log"
[nginx.conf]
location /test {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://Test;
}
upstream Test {
server unix:/var/www/Test/tmp/test.sock;
}
不同的 nginx 路径和 rb 路径
(For Example: hogehoge.com/test/)
[test.rb]
# coding: utf-8
require "sinatra"
require 'unicorn'
class Main < Sinatra::Application
get '/' do
'Success'
end
get '/test' do
'test Success'
end
not_found do
'not_found'
end
end
添加
get '/test' do
'test Success'
end