2012-06-27 31 views
2

使用橡胶我用resque和redis硫化了我现有的项目。我已全部部署。点击web_tools索引显示一个Resque链接。但点击它给了我一个404如何设置橡胶+ resque_web + nginx

我想通nginx的不知道该怎么用“/ resque”这样做,我添加的文件config/rubber/role/web_tools/resque-nginx.conf有:

<% if resque_host = rubber_instances.for_role('resque_web').first %> 

    <% 
    @path = "/etc/nginx/rubber/tools/resque.conf" 
    %> 

    location /resque 
    { 
    proxy_pass http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>; 
    } 

<% end %> 

基本上复制HAProxy的-nginx的。 conf文件来自同一个目录。

我的第一个问题是 - 我为什么要做这个?硫化应该做到这一点还是我已经做错了?

继续前进。这个nginx配置不起作用。但我有点进一步,至少我现在正在打WEBrick服务器。我有一个页面,说:

Sinatra doesn’t know this ditty. 

所以我改变了我的配置思想,Resque的使用WEBrick服务器不知道是什么/ resque是:

location /resque 
{ 
    rewrite ^/resque/(.*) /$1 break; 
    proxy_pass http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>; 
} 

这工作,但只有当我手动去https://myhost.com/resque/overview (Rubber添加到工具索引页面的链接仅为/resque)。但是,resque网页上的所有其他链接(包括任何CSS和.js文件)现在都已损坏,因为链接不以resque/开头。换句话说,Working的链接只是/working,但它需要/resque/working让nginx知道如何处理它。

我试过其他的东西,如摆脱重写和更改索引页面指向resque/overview,但仍然给我“Sinatra不知道这个小调”页面。

我已经试过:

location /resque 
{ 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>; 
} 

我得到的 “西纳特拉...小曲” 页面时,我打/resque/resque/overview

然后我说改写回:

location /resque 
{ 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    rewrite ^/resque/(.*) /$1 break; 
    proxy_pass http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>; 
} 

这是相同的结果为不具有所有代理的调用。

有谁知道如何让nginx的和Resque web服务器很好地协同工作?

回答

3

哇,真是太巧了。我正在从橡胶1.15 - > 2.0.5升级我们的应用程序,我昨天就遇到了这个问题!

是,rubber vulcanize resque应该照顾到这一点,但显然没有人写Nginx的代理CONFIGS。

你的第一次尝试Nginx的是几乎做了正确的事情。

究其原因,CSS,图片和链接被破坏是因为resque-网寻找相对resque-web应用程序的根目录中的所有东西。您需要更改resque-web Rack文件(/config/resque-web.ru)以启动/ resque子目录中的应用程序。这样一切都将是相对的(/ resque /概述,等等。)并罚款。

我昨天提交了一个pull request以解决未来用户的问题,但是您可以将这些更改应用到您的项目中,并且一切都将为您工作。

让我知道这是行不通的。

+0

太棒了!谢谢,尼克。我也会+1你的拉请求。我们最终在本地做的其他改变是摆脱美洲狮,并使用机架(在resque-web-upstart.conf中),因为美洲狮是不必要的。 – pcg79