我有在 unicorn+nginx 上运行的 Rails 应用程序。下面是 nginx.conf 和 unicorn.rb 配置。
nginx.conf
upstream unicorn {
server unix:/tmp/unicorn.todo.sock fail_timeout=0;
}
server{
listen 80 default deferred;
#server_name localhost;
root /var/www/demo/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
unicorn .rb
working_directory "/var/www/demo"
pid "/var/www/demo/tmp/pids/unicorn.pid"
stderr_path "/var/www/demo/unicorn.log"
stdout_path "/var/www/demo/unicorn.log"
listen "/tmp/unicorn.todo.sock"
worker_processes 2
timeout 30
它对我来说很好用。 现在我想部署另一个小的 sinatra app rails app sub uri(localhost:3000/sinatraapp)。详细信息:据我们所知,rails 应用程序在 localhost:3000 上运行,现在我正在尝试在 localhost:3000/sinatraapp 上配置 sinatra 应用程序。
请建议我,我将如何配置上述要求。
最佳答案
您可以简单地将您的 Sinatra 应用挂载到 Rails 的 routes.rb
中:
mount SinatraApp, :at => "/sinatraapp"
关于ruby-on-rails - 使用( unicorn 和 nginx)在 Rails 应用程序子 uri 上部署 sinatra 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17578087/