Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KoeusIss opened this issue Jan 24, 2023 · 1 comment

Comments

@KoeusIss
Copy link

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
@SOVRON
Copy link

SOVRON commented Jan 24, 2023

The issue is with your config.exs. Comment out https: [:inet6, port: 4443] and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants