Not able to view Phoenix app request error when built and deployed with distillery


I need help figuring out what is causing a 400 HTTP status code returned by Nginx when my Phoenix app is deployed with distillery. I recently upgraded Phoenix to 1.4 from 1.3.

None of the pages load and Nginx just returns 400.
There is nothing in the (distillery) logs and the app doesn’t crash.

When I attach to the running instance, the console (iex) doesn’t output anything when I try to load the page.

Is there a way to get the app to output something that would indicate where/why it fails?

Thank you

When you try to access the application directly, does it work then?

I’m not sure I understand what you did exactly: did you launched your release with the console task? If so, you won’t see runtime output there, you open an iex session and should be able to interact with the modules/functions.

To start the release you have built, you can use one of the following tasks:

    # start a shell, like 'iex -S mix'
    > _build/prod/rel/foobar/bin/foobar console

Let’s take a step back, how is your project deployed? Why do you have an Nginx reverse proxy in front of Phoenix?

Thanks for the reply @NobbZ . Nginx is setup with ssl termination using a self-signed cert. When I access my Phoenix app directly on the HTTP port it listens on, it works. I guess something goes wrong between Nginx and Phoenix. :thinking: I’m going to turn on Nginx debugging and see if I can get more output.

1 Like

Did you generate your certificate with mix phx.gen.cert?

If so, why are you using a proxy? This is obviously a developpement setup since you are using a self-signed certificate. You could setup your app’s Endpoint with SSL directly:

Thanks @gcauchon. Apologies for the delay - i’ve been off the grid for a few days. I launched the app with the ‘start’ task. When 'attach’ing to it, I can interact with it just fine. As stated above, I have Nginx fronting multiple (non-Phoenix) apps over SSL and then proxying requests to the apps over HTTP. Seems that something may be going wrong between Nginx and Phoenix, however, I am not yet able to determine whether my Phoenix app is receiving the request either incorrectly or not at all or is it Nginx that encounters an error.
Also, as @NobbZ asked, the app works fine when I request it directly and bypass Nginx and in my local dev environment running the app with “iex -S mix phx.server”.

Two other things I tried:

  • I turned off ssl on Nginx and it still doesn’t work - get a 400 bad request
  • When I deploy a 1.3 Phoenix version of the app, it works through Nginx over https and http, so this suggests the problem could be with the 1.4 Phoenix app

App is built using:

  • Distillery 1.5.5
  • Elixir 1.7.3
  • OTP 21 (erts-10.2.3)

I also include the erts in the build.

I found the problem. I have “proxy_set_header Host $host;” set in my location directive in Nginx. When I remove this it works.

1 Like

Hi @gcauchon. This is a development setup using a self-signed cert generated directly with openssl. Thanks for the info on the new certificate generation feature. I can probably skip the proxy completely and serve directly from Phoenix, unless I want Nginx to serve the static resources.