流星 - " ROOT_URL"的目的是什么?以及应该定义什么?

时间:2014-06-04 19:43:59

标签: nginx meteor

我在Ubuntu服务器上使用PhantomJS进行拼博工作时遇到了一些问题。我在Meteorpedia上看到了这个问题排查:

  

确保Meteor服务器配置使用的ROOT_URL   可以从服务器本身访问。 (自v0.8.1.3 [1])

我认为这可能是为什么它不起作用的可能答案。这个环境变量的目的是什么?

我的应用程序可在http://gentlenode.com/上公开访问,但我在nginx上的proxy_pass设置为http://gentlenode/

# HTTPS Server
server {
    listen 443;
    server_name gentlenode.com;
    # ...

    location / {
        proxy_pass http://gentlenode/;
        proxy_http_version 1.1;
        # ...
    }
}

我应该将ROOT_URL设置为http://gentlenode.com/,设置为http://gentlenode/还是设置为http://localhost/

您可以在此处找到我的nginx配置:https://gist.github.com/LeCoupa/9877434

2 个答案:

答案 0 :(得分:13)

ROOT_URL环境变量应设置为客户端将访问您的应用程序的URL。因此,在您的情况下,它将是http://gentlenode.comhttps://gentlenode.com

ROOT_URL环境变量由Meteor.absoluteUrl读取,spiderable用于许多(核心)包。因此,如果您使用这些包,则可能需要设置ROOT_URL。 {{3}}就是这样一个包。

// Line 62 of spiderable_server.js
var url = Spiderable._urlForPhantom(Meteor.absoluteUrl(), req.url);

答案 1 :(得分:2)

我承认我们不使用spiderable所以我不是百分之百确定这是否能解决你的问题,但这就是我们所做的......

我们将ROOT_URL设置为客户端将用于初始连接的URL。在您的情况下,nginx配置会自动将所有HTTP请求升级到HTTPS,因此您的应用将在https://gentlenode.com下看到所有请求。我想你应该在以下之后启动你的服务器:

export ROOT_URL=https://gentlenode.com

您的proxy_pass部分可能是正确的。我们手动拼出本地端口的名称。所以我们写道:

proxy_pass http://localhost:58080;

如果你已经有了可行的东西,这可能没有必要。我不知道nginx的所有怪癖是否足以说明这一部分是否重要。

相关问题