Nginx背后的多个流星站点 [英] Multiple Meteor sites behind Nginx

查看:68
本文介绍了Nginx背后的多个流星站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与

This question is related to this SO question, but the recommended solution in the comments to use Meteor.absoluteUrl() doesn't seem to be working as expected. I want to be able to deploy multiple meteor applications to the same server and use nginx as a reverse proxy to each application.

由于每个应用程序都是隔离的,因此无法从ROOT_URL访问任何应用程序,但是Meteor仅使用ROOT_URL来引用需要加载流星应用程序的资产.

Because each application is segregated none of the applications are going to be accessible from the ROOT_URL, but Meteor is only using the ROOT_URL to reference back for the assets it needs to load a meteor app.

我尝试在服务器的启动,客户端的启动功能以及客户端的启动功能之外使用Meteor.absoluteUrl()附加到地址.在这些地方都没有影响.

I tried appending to the address using Meteor.absoluteUrl() in the server's startup, the client's startup function, and outside of the client's startup function. It had no affect in any of these places.

例如.我有Nginx在/site1上侦听server_name:example.com和流星应用程序的端口3001的反向代理.

For example. I have nginx listening at /site1 for server_name: example.com and a reverse proxy to port 3001 to my meteor application.

转到该网站时,它最初加载正常,但浏览器开发工具显示Meteor正在尝试在 https上查找javascript和css文件. ://example.com 应该从 https://example.com/site1

When going to the site it initially loads fine but the browser dev tool shows Meteor is trying to find the javascript and css files at https://example.com when it should be looking from a base url of https://example.com/site1

Meteor.absoluteUrl("site1",{ssl:true})尝试将其强制为正确的路径.如您所见,我仅将ROOT_URL附加到流星文档中,而没有前导/.

Meteor.absoluteUrl("site1",{ssl:true}) was set in Meteor.startup() to try and force that as the correct path. As you can see, I am only appending to ROOT_URL with no leading / as described in the Meteor documentation.

我正在使用流星进行部署,这是mup.json环境设置的外观:

I'm using meteor up to deploy and here's how the mup.json environment settings look:

"env":{ "ROOT_URL":" https://example.com ", 端口":3001, "MONGO_URL":"mongodb://user:password @ localhost:27017/db" }

"env": { "ROOT_URL": "https://example.com", "PORT": 3001, "MONGO_URL": "mongodb://user:password@localhost:27017/db" }

对此应做的任何澄清,我们将不胜感激.

Any clarification about this this should work is greatly appreciated.

推荐答案

使用apendua建议的子域似乎是在nginx后面的同一服务器上容纳多个Meteor应用程序的最简单方法(如果您可以使用该选项) .

Using sub-domains suggested by apendua seems to be the easiest way to accommodate multiple Meteor applications on the same server behind nginx (if you that option available to you).

  1. 为每个应用程序注册一个子域(即app1.domain.com,app2.domain.com等)
  2. 为每个子域添加一个nginx服务器配置,将server_name属性设置为您的子域地址.
  3. 为该服务器添加默认位置,并将proxy_pass设置为 http://127.0.0.1:port ,其中port是您在部署Meteor应用程序时在环境配置中设置的端口号(在我的情况下,我在mup.json中设置了此端口号).
  1. Register a sub-domain for each application (i.e. app1.domain.com, app2.domain.com, etc.)
  2. Add an nginx server configuration for each sub-domain, setting the server_name property to your sub-domain address.
  3. Add a default location for that server and set your proxy_pass to http://127.0.0.1:port where port is the port number you set in your environment configuration when you deployed your Meteor application (in my case I set this in my mup.json).

这篇关于Nginx背后的多个流星站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆