erlangelixirphoenix-frameworknitrous

Elixir Phoenix web server cannot be previewed on Nitrous.io


After installing Elixir 0.14.1 and the Phoenix web framework then launching the web server I am unable to preview the web site. Does anyone know how to get this working?


Solution

  • Nitrous currently does not have explicit support for Elixir boxes so you have to create a box using any of the supported services (i.e. Ruby on Rails). Then you can use Autoparts:Uninstall to remove the unneeded parts and Autoparts:Install to add Elixir (currently there is an Elixir 0.14.1 part which shows up if you search).

    Once Elixir is installed, open up a Nitrous console and install the latest Phoenix framework by cloning from github as documented by the README.md on the phoenixframework github site.

    Create a Phoenix application in the console from the phoenix root directory, as described in the README.md. In the discussion below we assume the phoenix app is named ws.

    The Nitrous IDE preview feature requires that the webserver runs on 0.0.0.0 using port 3000 (other ports are also supported) with ssl turned off. To do this, modify /lib/ws/config/prod.ex to look like:

    defmodule Ws.Config.Prod do
      use Ws.Config
    
      config :router, port: 4000,
                      host: "0.0.0.0",
                      ip: {0, 0, 0, 0},
                      ssl: false,
                      # Full error reports are disabled
                      consider_all_requests_local: false
    
      config :plugs, code_reload: false
    
      config :logger, level: :error
    end
    

    Note that we're modifying the production configuration. You may decide do use the dev.ex or config.ex configuration as well/instead. To start the server from within the Nitrous console, make sure you are in the application's root directory then enter:

    MIX_ENV=prod mix phoenix.start

    to start the server. You should now be able to preview the resulting site from within the Nitrous IDE using the Preview:Port 3000.