How to start foreman dev instance on an interface

Hey,

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.

1 Like

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:

#!/bin/sh
export BIND=192.168.13.4
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:

#!/bin/sh
export BIND=192.168.1.42
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 myhost.example.com"

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.

Hello, i have similar issue.
I am installed Foreman Katello devel with forklift on my virtual machine without vagrant.
On machine i run this:

git clone https://github.com/theforeman/forklift.git
cd forklift/
ansible-galaxy collection install -r requirements.yml
cp vagrant/boxes.d/99-local.yaml.example vagrant/boxes.d/99-local.yaml
sed -i.bak "s/<REPLACE ME>/maccelf/g" vagrant/boxes.d/99-local.yaml
useradd vagrant
echo "vagrant   ALL=(ALL)   NOPASSWD: ALL" >> /etc/sudoers
firewall-cmd --add-port="80/tcp" --add-port="443/tcp" --add-port="5647/tcp" --add-port="8000/tcp" --add-port="8140/tcp" --add-port="9090/tcp" --add-port="53/udp" --add-port="53/tcp" --add-port="67/udp" --add-port="69/udp" --add-port="5000/tcp" firewall-cmd --add-port="3808/tcp" 
firewall-cmd --runtime-to-permanent
firewall-cmd --reload
ansible-playbook --private-key=~/.ssh/id_rsa --user root --inventory inventories/localhost --extra-vars katello_devel_github_username=maccelf playbooks/katello_devel.yml

Then on vagrant user i run this:

cd foreman
bundle install
npm install
bundle exec foreman start

But I didn’t see anything in browser
In console i have errors:

GET https://192.168.246.50:3808/webpack/bundle.css net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/foreman_remote_execution:global.css net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/katello:fills.css net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/foreman-vendor.bundle-v8.9.0-development-bbbb22a12f604c1ed0ff.css net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/foreman-vendor.bundle-v8.9.0-development-bbbb22a12f604c1ed0ff.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/vendor.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/bundle.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack-dev-server.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
application-a5772921c7b1e7c112fa509bff3e184cda146f2f7cd03b737ab38fa51a9a7c1e.js:8 Uncaught Error: Bootstrap's JavaScript requires jQuery
    at application-a5772921c7b1e7c112fa509bff3e184cda146f2f7cd03b737ab38fa51a9a7c1e.js:8
(anonymous) @ application-a5772921c7b1e7c112fa509bff3e184cda146f2f7cd03b737ab38fa51a9a7c1e.js:8
GET https://192.168.246.50:3808/webpack/foreman_remote_execution:global.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY
GET https://192.168.246.50:3808/webpack/katello:fills.js net::ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY

There is my .env

BIND=0.0.0.0
PORT=3000
RAILS_STARTUP='puma -w 2 -p $PORT --preload'
WEBPACK_OPTS='--https --key /etc/pki/katello/private/katello-apache.key --cert /etc/pki/katello/certs/katello-apache.crt --cacert /etc/pki/katello/certs/katello-default-ca.crt --host 0.0.0.0 --public 192-168-246-50.atm.cloudlinux.com'
REDUX_LOGGER=false

So, maybe i missed something or did anything wrong ?

Can anyone help with this?

It’s probably not related, but looks like you have and extra firewall-cmd there before port 3808.

This should be fixed by Fixes #32437 - fix webpack-dev-server h2 issue by laviro · Pull Request #8475 · theforeman/foreman · GitHub - I thought we had that merged already but looks like it’s not there yet. You could manually apply the patch to your instance and hopefully it will resolve the issue for you.

2 Likes

Thanks a lot, i applied the patch reinstalled npm package and webpack works fine

1 Like

And I just merged it now so you shouldn’t need to manually do that in the future :slight_smile:

2 Likes