【问题标题】:How can I deploy an Ember app on Digital Ocean?如何在 Digital Ocean 上部署 Ember 应用程序?
【发布时间】:2017-05-16 16:15:42
【问题描述】:

我有一个在端口 4200 上运行的 Ember 应用程序,它在端口 4500 上使用 Express API。我已将我的 API 上传到:

/var/www/my-api-domain.com/public_html/

我还编辑了 nginx sites-available 文件:

location /
{
    proxy_pass http://localhost:4500;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

我通过 SSH 连接到服务器,将目录更改为我的 API,然后运行 ​​node server,这样就可以了!当我在浏览器中访问我的 IP 时,我看到我的 API 工作正常:

http://159.203.31.72

然后我在本地运行 ember build -prod 并将生成的 dist 文件夹的内容上传到:

/var/www/my-ember-domain.com/public_html/

我再次将 nginx sites-available 更新为:

location /ember
{
    proxy_pass http://localhost:4200;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

现在呢?通常,当我在本地运行站点时,我会运行ember server,但dist 中的结果文件看起来大不相同,而且我没有在服务器上安装ember cli。当我读到它时,这似乎不是正确的方法。

当我在浏览器中点击 http://159.203.31.72/ember 时,我得到一个 nginx 502 Bad Gateway。如何为我的 Ember 应用提供服务?

【问题讨论】:

    标签: nginx ember.js deployment port digital-ocean


    【解决方案1】:

    ember server 启动一个不应用于生产的开发服务器。使用ember build --prod 构建您的应用程序。之后,您将在 dist/ 文件夹中找到您的资产。用 nginx 服务那些,你就完成了。在 ember-cli 文档中有一个示例 nginx.conf:https://ember-cli.com/user-guide/#deploying-an-https-server-using-nginx-on-a-unixlinuxmacosx-machine

    如果您必须设置更复杂的部署工作流程,您可以使用ember-cli-deploy。

    【讨论】:

      猜你喜欢
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      • 2019-01-26
      • 2015-01-04
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多