如何设置与Nginx背后的凤凰城的Websockets?

如何设置与Nginx背后的凤凰城的Websockets?,第1张

概述如何设置与Nginx背后凤凰城的Websockets?

我试图设置networking套接字通过Nginx的凤凰应用程序,但不断收到403错误。 任何人都可以build议正确的configuration,使这项工作在生产 – 开发env是好的。

我的Nginx conf:

upstream phoenix { server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; } server { server_name <app-domain>; Listen 80; location / { allow all; # Proxy headers proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Cluster-ClIEnt-Ip $remote_addr; # The important Websocket Bits! proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://phoenix; } }

我的prod.exs conf:

use Mix.Config config :logger,level: :info config :phoenix,:serve_endpoints,true config :app,App.Endpoint,http: [port: 4000],url: [host: "127.0.0.1",port: 4000],root: '.',cache_static_manifest: "priv/static/manifest.Json",server: true config :app,App.Repo,username: System.get_env("MONGO_USERname"),password: System.get_env("MONGO_PASSWORD"),database: "template",hostname: "localhost",pool_size: 10

如有需要,我可以根据要求提供其他信息。

http 500将Elixir / Phoenix部署到AWS Elastic Beanstalk

突然 – tcp connect(localhost:5432):连接被拒绝 – :econnrefused

如何在windows 8.1上运行Elixir escript

如何设置Elixir项目通过amqp使用RabbitMQ?

在窗户上的Erlang透析器

该应用程序可以很好地到达域名,最后和唯一剩下的问题是让networking套接字工作。

非常感谢任何能指引我正确方向的人。

Elixir凤凰 – 跟踪连接重置通过同行错误

我跟着凤凰网站的指南。 Exrm发行 – 凤凰

你的Nginx.config缺少这个:

# The following map statement is required # if you plan to support channels. See https://www.Nginx.com/blog/websocket-Nginx/ map $http_upgrade $connection_upgrade { default upgrade; '' close; }

在将版本发布到服务器之后,在本地计算机中生成发行版时,我也遇到了一些错误。

所以我建议你应该在服务器环境中生成你的版本。

编辑:

浏览器控制台错误:

ws://phoenix.hollyer.me.uk/socket/websocket?token=&vsn=1.0.0' Failed: Error during WebSocket handshake: Unexpected response code: 403

这可能是这个错误。你应该尝试在你的服务器里启动你的控制台:

[error] Could not check origin for Phoenix.socket transport. This happens when you are attempting a socket connection to a different host than the one configured in your config/ files. For example,in development the host is configured to "localhost" but you may be trying to access it from "127.0.0.1". To fix this issue,you may either: 1. update [url: [host: ...]] to your actual host in the config file for your current environment (recommended) 2. pass the :check_origin option when configuring your endpoint or when configuring the transport in your UserSocket module,explicitly outlining which origins are allowed: check_origin: ["https://example.com","//another.com:888","//other.com"]

所以你可以重新配置你的主机:

[url: [host: "http://www.phoenix.hollyer.me.uk"]]

或者将check_origin选项传递给您的端点配置或UserSocket模块:

check_origin: ["http://www.phoenix.hollyer.me.uk"]

然后尝试再次部署。希望能帮助你!

总结

以上是内存溢出为你收集整理的如何设置与Nginx背后的凤凰城的Websockets?全部内容,希望文章能够帮你解决如何设置与Nginx背后的凤凰城的Websockets?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1232129.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存