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

Error when running main_proxy: could not start Cowboy2 adapter, missing option :key/:keyfile #33

Open
hawkyre opened this issue May 1, 2023 · 1 comment

Comments

@hawkyre
Copy link

hawkyre commented May 1, 2023

I'm getting the following error when running this proxy.

22:24:25.238 [notice] Application main_proxy_app exited: MainProxyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: MainProxyApp.Proxy
** (EXIT) an exception was raised:
** (ArgumentError) could not start Cowboy2 adapter, missing option :key/:keyfile

I just set up a new umbrella project for my server and can't run it due to this. This is the proxy file

defmodule MainProxyApp.Proxy do
  use MainProxy.Proxy

  @impl MainProxy.Proxy
  def backends do
    [
      %{
        domain: Application.get_env(:main_proxy_app, :language_league_api_server_url),
        plug: LLServer.Web.Router
      }
    ]
  end
end

any idea on how to fix it?

@johnnyMick
Copy link

Here is my fix for the issue for an umbrella project
you can open iex also in your project directory with PROXY_SERVER=false iex -S mix

# Config Main Proxy
# this is need to stop from starting poxy server, in iex -S mix
maybe_server = System.get_env("PROXY_SERVER") || "true"
config :main_proxy,
  server: maybe_server === "true", # This is required for the proxy to work
  force_ssl: [hsts: true], # force SSL
  # http: [port: 4000],
  https: [
    port: 4001,
    otp_app: :app, # umbrella project
    compress: true,
    cipher_suite: :strong,
    certfile: "priv/cert/selfsigned.pem",
    keyfile: "priv/cert/selfsigned_key.pem"
  ]

and then you will need to specify your other app to load in https or the assets will load in http

config :app2, App2.Endpoint,
  server: false, # This is required for the proxy to work
  force_watchers: true, # forces your watchers to start even when the `:server` option is set to `false`
  force_ssl: [hsts: true], # force SSL
  https: [cipher_suite: :strong],  # force SSL
  url: [host: "my-app.local"],
  static_url: [host: "my-app.local"],
  
  
config :app3, App3.Endpoint,
  server: false, # This is required for the proxy to work
  force_watchers: true, # forces your watchers to start even when the `:server` option is set to `false`
  force_ssl: [hsts: true], # force SSL
  https: [cipher_suite: :strong],  # force SSL
  url: [host: "admin.my-app.local"],
  static_url: [host: "my-app.local"],

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