Skip to content

Could not start application master_proxy: MasterProxy.Application.start(:normal, []) #30

@KoeusIss

Description

@KoeusIss

I'm trying to implement the main proxy in order to dispatch http requests among an api and backoffice app. I followed the documentation steps as it is, but the project runs to fail
Versions:

main_proxy 0.2.0
phoenix 1.6.15
plug_cowboy 2.6.0

Application file

defmodule MasterProxy.Application do
  @moduledoc false

  use Application

  @impl true
  def start(_type, _args) do
    children = [
      MasterProxy.Proxy
    ]

    opts = [strategy: :one_for_one, name: MasterProxy.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

config.exs

config :main_proxy,
  http: [:inet6, port: 4080],
  https: [:inet6, port: 4443]

Proxy module

defmodule MasterProxy.Proxy do
  use MainProxy.Proxy

  @impl MainProxy.Proxy
  def backends do
    [
      %{
        host: ~r{^api\*_$},
        phoenix_endpoint: HttpApiWeb.Endpoint
      }
    ]
  end
end

Issue

$ mix run --halt
[info] [main_proxy] Listening on http with options: [{:port, 4080}, {:dispatch, [_: [{:_, MainProxy.Cowboy2Handler, {nil, [backends: [%{host: ~r/^api\*_$/, phoenix_endpoint: HttpApiWeb.Endpoint}], callback_module: MasterProxy.Proxy]}}]]}, :inet6]
[info] [main_proxy] Listening on https with options: [{:port, 4443}, {:dispatch, [_: [{:_, MainProxy.Cowboy2Handler, {nil, [backends: [%{host: ~r/^api\*_$/, phoenix_endpoint: HttpApiWeb.Endpoint}], callback_module: MasterProxy.Proxy]}}]]}, :inet6]
[notice] Application master_proxy exited: MasterProxy.Application.start(:normal, []) returned an error: shutdown: failed to start child: MasterProxy.Proxy
    ** (EXIT) an exception was raised:
        ** (ArgumentError) could not start Cowboy2 adapter, missing option :key/:keyfile
            (plug_cowboy 2.6.0) lib/plug/cowboy.ex:409: Plug.Cowboy.fail/1
            (plug_cowboy 2.6.0) lib/plug/cowboy.ex:167: Plug.Cowboy.args/4
            (plug_cowboy 2.6.0) lib/plug/cowboy.ex:261: Plug.Cowboy.child_spec/1
            (elixir 1.14.3) lib/supervisor.ex:696: Supervisor.init_child/1
            (elixir 1.14.3) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
            (elixir 1.14.3) lib/supervisor.ex:687: Supervisor.init/2
            (stdlib 4.2) supervisor.erl:330: :supervisor.init/1
            (stdlib 4.2) gen_server.erl:851: :gen_server.init_it/2
            (stdlib 4.2) gen_server.erl:814: :gen_server.init_it/6
            (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
[notice] Application main_proxy exited: :stopped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions