【发布时间】: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 工作正常:
然后我在本地运行 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