【问题标题】:Nginx not displaing Phoenix web appNginx 不显示 Phoenix Web 应用程序
【发布时间】:2016-06-11 18:06:12
【问题描述】:

我正在尝试将基本的 Phoenix 应用程序部署到运行 ubuntu 14.04 的 DigitalOcean 服务器。我正在使用 exrm 生成版本。当我在本地机器和服务器上测试它时,该版本有效。我正在关注deployment 上的 Phoenix 指南。似乎不起作用的是 nginx 服务器设置的最后一部分。出于某种原因,除了默认页面之外,我无法让它加载任何内容。当我运行

nginx -t # 命令。它说一切都很好。

我尝试编辑 /etc/nginx/sites-available 文件。似乎什么都没做。我试过用

重启 nginx 服务器

sudo 服务 nginx 重新加载 sudo service nginx 重启

但这似乎也不起作用。 这是我的 /etc/nginx/sites-available/my_app.conf 的内容

upstream my_app {
server 127.0.0.1:4000;
}

server{
listen 80;
server_name www.example.com;

location / {
    try_files $uri @proxy;
}

location @proxy {
    include proxy_params;
    proxy_redirect off;
    proxy_pass http://my_app;
    # The following two headers need to be set in order
    # to keep the websocket connection open. Otherwise you'll see
    # HTTP 400's being returned from websocket connections.
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}

}

更新:尝试通过 server_ip:port 直接连接,并且成功了。网址仍然没有显示任何内容。

已解决:出于某种原因,删除它可以解决问题。:

proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade;

【问题讨论】:

  • 我今天在部署 Phoenix 时发现,在MIX_ENV=prod 中运行时(exrm 版本可能会这样做),默认配置设置没有指定端口(相反,他们想要读取 env PORT 变量),也许这里就是这种情况?
  • 我将 4000 指定为端口变量,所以可能不是。
  • 您是不是要使用proxy_pass http://email_bot; 而不是proxy_pass http://my_app;
  • 修复后没有任何改变。
  • 你提到了/etc/nginx/sites-available/etc/nginx/sites-enabled呢?

标签: nginx phoenix-framework


【解决方案1】:

已解决:出于某种原因,删除它可以解决问题。

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 2016-08-16
    • 2013-07-06
    • 1970-01-01
    • 2015-09-09
    • 2017-07-31
    相关资源
    最近更新 更多