【问题标题】:Deploying sinatra app on rails app sub uri using( unicorn and nginx)使用(独角兽和nginx)在rails app sub uri上部署sinatra app
【发布时间】:2013-07-08 19:44:12
【问题描述】:

我有在 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;
}

独角兽.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 应用程序。

请建议我,我将如何配置上述要求。

【问题讨论】:

    标签: ruby-on-rails nginx sinatra unicorn


    【解决方案1】:

    您可以在 Rails 的routes.rb 中简单地挂载您的 Sinatra 应用程序:

    mount SinatraApp, :at => "/sinatraapp"
    

    【讨论】:

    • 根据我的要求,我不必修改rails代码。我可以添加符号链接,ln -s /var/www/sinatraapp/public /var/www/demo/logs,但它不起作用。
    猜你喜欢
    • 2012-04-01
    • 2023-03-20
    • 2013-01-10
    • 2015-09-27
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 2012-09-11
    • 2020-10-17
    相关资源
    最近更新 更多