How to start foreman dev instance on an interface


I am trying to start a dev setup on a particular interface. Here is my startup script:

export BIND=192.168.X.Y
bundle exec foreman start

Both webpack and rails start on the correct interface, but when I try to access it I am getting:

18:47:48 rails.1   |  d04c2446 | ActionView::Template::Error (Could not load manifest from webpack-dev-server at http://localhost:3808/webpack/manifest.json - is it running, and is stats-webpack-plugin loaded? (original error Failed to open TCP connection to localhost:3808 (Connection refused - connect(2) for "localhost" port 3808))):
18:47:48 rails.1   |  d04c2446 |     10: 
18:47:48 rails.1   |  d04c2446 |     11:     <%= favicon_link_tag "favicon.ico"%>
18:47:48 rails.1   |  d04c2446 |     12: 
18:47:48 rails.1   |  d04c2446 |     13:     <%= stylesheet_link_tag *webpack_asset_paths('foreman-vendor', :extension => 'css') %>
18:47:48 rails.1   |  d04c2446 |     14:     <%= stylesheet_link_tag *webpack_asset_paths('bundle', :extension => 'css') %>
18:47:48 rails.1   |  d04c2446 |     15:     <%= stylesheet_link_tag 'application' %>
18:47:48 rails.1   |  d04c2446 |     16:     <%= webpacked_plugins_with_global_css %>
18:47:48 rails.1   |  d04c2446 |   

I think I need to tell somehow Rails to use the interface instead of localhost but I do not know how.

Please help. Cheers! Have a good one.

If I’m reading config/webpack.config.js correctly, you should be able to set WEBPACK_OPTS environment variable to --host=192.168.X.Y. This should be then honored by webpack devserver.

Another piece of the puzzle is configuring rails to actually reach out there when retrieving a webpack manifest. The only way I found is to add config.webpack.dev_server.manifest_host = '192.168.X.Y' into config/environments/development.rb

Yeah, I already tried both --host IP and --host=IP but nothing really works. Here is my full script just for the record:

export BIND=
export WEBPACK_OPTS="--host=$BIND"
cd $HOME/work-nfs/foreman
$HOME/.rbenv/shims/bundle exec foreman start

Oh, this almost did it. I my webpack instance was replying with “Invalid Host header” so I googled it and added --pubic FQDN and now it works! Thanks.

For the record, this is how you start Foreman dev instance on a different NIC:

export BIND=
export WEBPACK_OPTS="--host $BIND --public FQDN"
bundle exec foreman start

Actually, I figured out how to run Foreman without the mentioned change in development.rb:

# Foreman ENV
export BIND=::
export WEBPACK_OPTS="--host $BIND --public"

bundle exec foreman start

For reference, this is what’s used in the katello devel setup:

It’s written to .env so you don’t have to remember it.