I am unable to connect to my Linux Container's web page. I am following Udemy's course on Reactjs and Redux and cloned the ReduxSimpleStarter repo from Github.
I've ran npm install with no issues and then ran npm start
jason@courses:~/udemy/react1/ReduxSimpleStarter$ npm start
> [email protected] start /home/jason/udemy/react1/ReduxSimpleStarter
> node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js
http://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from ./
404s will fallback to /index.html
Hash: e1867813ff617d08f0b8
Version: webpack 1.15.0
Time: 10928ms
Asset Size Chunks Chunk Names
bundle.js 746 kB 0 [emitted] main
chunk {0} bundle.js (main) 706 kB [rendered]
[0] multi main 28 bytes {0} [built]
[1] ./src/index.js 854 bytes {0} [built]
[2] ./~/react/react.js 56 bytes {0} [built]
[3] ./~/react/lib/React.js 1.49 kB {0} [built]
...
...
[198] ./~/invariant/browser.js 1.52 kB {0} [built]
[199] ./src/components/app.js 2.21 kB {0} [built]
[200] ./src/reducers/index.js 337 bytes {0} [built]
webpack: Compiled successfully.
I navigate to the the url address shown by lxc list
for example, 10.123.123.12
Navigating to 10.123.123.12:8080 gives me "Unable to Connect"
I finally settled with the following configurations.
In my container, I used iptables to re-route incoming traffic of port 80 to port 8080.
sysctl -w net.ipv4.conf.all.route_localnet=1
iptables -t nat -I PREROUTING -p tcp --dport 80 -j DNAT --to 127.0.0.1:8080
Then changing the webpack.config.js file by adding disableHostCheck : true to the devServer hash.
devServer {
...,
...,
disableHostCheck: true
}
Be careful with the last directive as it could be a security risk however, this is a Linux Container on my laptop so I'm not too worried about it.
I can now navigate to 10.123.123.12 (not 10.123.123.12:8080) and see my app.