【问题标题】:Phoenix umbrella app with sub-domains on the same port凤凰伞应用程序在同一端口上具有子域
【发布时间】:2017-08-01 07:35:59
【问题描述】:

我正在尝试在同一端口上创建一个包含多个应用程序的 Phoenix 伞式项目。使用我当前的配置,我收到此错误:

⧕ /m/i/d/p/e/portfolio on master * ⟩mix phoenix.server                                                                                                                                   13m 20s 412ms
==> rumbl
Compiling 17 files (.ex)
Generated rumbl app
[info] Running Rumbl.Endpoint with Cowboy using http://localhost:8080
[error] Failed to start Ranch listener Persona.Endpoint.HTTP in :ranch_tcp:listen([port: 8080]) for reason :eaddrinuse (address already in use)

[info] Application persona exited: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
        ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
            ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
                ** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}
** (Mix) Could not start application persona: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
        ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
            ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
                ** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}

我的伞形项目的详细信息是我目前有 3 个应用程序。 1 个应用代理对其他 2 个应用的请求。代理应用是一个基本的插件应用。

# /apps/proxy/lib/proxy/plug.ex
...
  def call(conn, _opts) do
    cond do
      conn.host =~ ~r{rumbl.} ->
        Rumbl.Endpoint.call(conn, [])
      true ->
        Persona.Endpoint.call(conn, [])
    end
  end
...

角色应用

# /apps/persona/config/dev.exs
...
config :persona, Persona.Endpoint,
  http: [port: 8080],
  debug_errors: true,
  code_reloader: true,
  check_origin: false,
  watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
                    cd: Path.expand("../", __DIR__)]]

...

Rumbl.app

# /apps/rumbl/config/dev.exs
config :rumbl, Rumbl.Endpoint,
  http: [port: 8080],
  debug_errors: true,
  code_reloader: true,
  check_origin: false,
  watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
                    cd: Path.expand("../", __DIR__)]]

我的要求是因为我使用 nanabox.io 进行开发和部署,它要求所有 http/https be received on port 8080

【问题讨论】:

    标签: elixir web-deployment phoenix-framework continuous-deployment nanoboxio


    【解决方案1】:

    如果您的代理端点无论如何都接收到所有流量,请将另外 2 个的端口设置为随机的,这样端口就不会发生冲突。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-01
      • 2022-01-24
      • 2019-10-17
      • 2018-04-04
      • 2017-09-15
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      相关资源
      最近更新 更多