简体   繁体   English

如何从与根不同的路由(在Nginx代理后面)运行流星?

[英]How to run meteor from a route different from root (behind nginx proxy)?

I have a meteor app running on port 3000 我有一个运行在端口3000上的流星应用程序

now http://1.2.3.4:3000 works as expected. 现在http://1.2.3.4:3000可以正常工作。

I'm trying to run expose the meteor app as a directory outside of the document root, so on the same box, I have nginx running on port 80 configured like so: 我正在尝试将流星应用程序公开显示为文档根目录之外的目录,因此在同一框上,我让运行在端口80上的nginx配置如下:

server {

  ...

  server_name my.test.com

  ...

  location /meteor{
    proxy_redirect off;
    proxy_set_header   X-Real-IP            $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host                   $http_host;
    proxy_set_header   X-NginX-Proxy    true;
    proxy_set_header   Connection "";
    proxy_http_version 1.1;
    proxy_pass  http://localhost:3000;
  }

  ...

}

Now when I load http://1.2.3.4/meteor I get: 现在,当我加载http://1.2.3.4/meteor我得到:

<script type="text/javascript">
__meteor_runtime_config__ = {"ROOT_URL":"meteor","serverId":"ABC12345"};
</script>

<script type="text/javascript" src="/26b7ea5a393eddd33c2278e17dc1d537732e9553.js"></script>

Noe that it's trying to include js from the root route src="/26b7e... so it's failing. 注意,它试图从根路由src =“ / 26b7e ...中包含js ...,所以它失败了。

I've found some information suggesting that the ROOT_URL env variable needs to be set. 我发现一些信息提示需要设置ROOT_URL env变量。 I've set that to "meteor", which is the name of my route in nginx but it doesn't seem to affect the behaviour of this. 我已将其设置为“ meteor”,这是我在nginx中的路线名称,但似乎并不影响此行为。 I think that variable only changes how Meteor.absoluteUrl works. 我认为该变量只会更改Meteor.absoluteUrl的工作方式。

How do I tell meteor where to include its resources from? 我如何告诉流星在哪里包括其资源? I don't want to run meteor on the root / route. 我不想在根/路由上运行流星。

It appears that this wasn't supported before Meteor 0.6.5. 看来在Meteor 0.6.5之前不支持此功能。

The following was added on v0.6.5+ v0.6.5 +上添加了以下内容

ROOT_URL may now have a path part. ROOT_URL现在可能包含路径部分。 This allows serving multiple Meteor apps on the same domain. 这允许在同一域上提供多个Meteor应用程序。

So setting the ROOT_URL environment variable enables the behaviour I was looking for. 因此,设置ROOT_URL环境变量将启用我一直在寻找的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM