Browsersync within Vagrant VM does not properly proxy - node.js

I'm having an issue where browser-sync is not properly proxying my apache2 server. I'm running browser-sync through gulp within an Ubuntu 14.04 VM with Ubuntu 15.04 on the host. I'm using the following configuration:
browserSync({
proxy: 'localhost:80',
port: '8081',
open: false
});
The guest machine's port 80 is mapped to 8080 on the host. The gulp task runs without issue and I get the expected output from browser-sync. If I visit localhost:8081/index.php, it works without any issue. If I try to visit localhost:8081/foo/index.php, however, my browser is redirecting to localhost:8080/foo/index.php, and browser-sync does not function.
If I set logLevel to debug, I see output when I visit localhost:8081/index.php:
[BS] Browser Connected: Chrome, version: 45.0.2454.85
There is no output, however, when I visit localhost:8081/foo/index.php
Is there a bug with browser-sync when used within a VM?

Related

Nodejs app in Docker not accessible on localhost:3000

I am trying to run a Node application in a Docker container. The installation instructions specified that after adding host: '0.0.0.0' to config/local.js and running docker-compose up the app should be accessible at localhost:3000, but I get an error message in the browser saying "The connection was reset - The connection to the server was reset while the page was loading."
I have tried to add the host: '0.0.0.0' in different places, or remove it entirely, access https://localhost:3000 as opposed to at http, connecting to localhost:3000/webpack-dev-server/index.html, etc.
What could be going wrong?

Can't connect to Jekyll's localhost:4000 on Windows 10

I'm trying to set up Jekyll on my Windows 10 machine, but can't connect to the website (127.0.0.1:4000) that is created by jekyll serve (or bundle exec jekyll serve). I have followed all the steps in Julian Thilo's Run Jekyll on Windows without any error messages. And when I run jekyll serve in PowerShell from my Jekyll website folder everything seems just fine:
Configuration file: C:/Users/fredr/dropbox/github/jekyll-website/_config.yml
Source: C:/Users/fredr/dropbox/github/jekyll-website
Destination: C:/Users/fredr/dropbox/github/jekyll-website/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.457 seconds.
Auto-regeneration: enabled for 'C:/Users/fredr/dropbox/github/jekyll-website'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
But when I open http://127.0.0.1:4000 (or http://localhost:4000) in my browser, the connection fails.
When I run netstat -an, the port 4000 is listed as
Proto Local Address Foreign Address State
TCP 127.0.0.1:4000 0.0.0.0:0 LISTENING
I have previously managed to set up a localhost using IIS, but that website is stopped now.
This Github issue seems related, but doesn't contain enough information for me to figure out how the problem was solved. It only says to use the "Jekyll on windows package", but I can't find any information on that.
Following in #Fredrik P's footsteps, I CD'd into the project's _site folder (this is where the home folder of the server should be) and ran a Python 3.x simple HTTP server:
D:\frida\frida-website\_site>python -m http.server 3999
Serving HTTP on 0.0.0.0 port 3999 (http://0.0.0.0:3999/) ...
Now pointing my browser to http://0.0.0.0:3999/ works like a charm.
If you need to use Python 2.x, the HTTP server command would be:
python -m SimpleHTTPServer 3999
For more information regarding SimpleHTTPServer (2.x) and http.server (3.x), see this Stack Overflow post.
Until some better solution pops up, I will just host the _site folder with IIS. Not as fancy pancy but works like a charm :)

Node Debug From Vagrant

Unable to remote debug a node server running on a Vagrant box in Chrome from my host machine. The server is configured to run on port 8123.
Node Version: 7.10.0
In Vagrantfile:
config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123
From my vagrant box I run:
$ node --inspect index.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/84085f07-dc42-4e1e-bdd8-532e6dc5c4c6
--- Customer Service---
Connecting to customer repository...
Connected. Starting server...
Server started successfully, running on port 8123.
When I try to access the url in Chrome from my host machine while I don't get an error the sources tab is empty.
Screenshot of devTools
Based on NodeJS 11591 issue. You can't access the Vagrant stuff via localhost (127.0.0.1), so you need to to specify host explicitly:
$ node --inspect=0.0.0.0:9229 index.js
Then you need to set up Target discovery settings in the Chrome. Note that 192.168.33.11 from my sample is the static IP address providing an access to the Vargant host from the local host:

Access Vue Application on Webpack-Server in Vagrant

I set up a virtual machine with Vagrant, ubuntu xenial64, installed npm/nodejs and the vue-cli.
I scaffolded a webpack application with vue init webpack myproject. When I now run npm run devthe webpack server starts, but since it's inside the virtual machine I can't access the webpage on my PC.
I found out, that you can run webpack server with --host 0.0.0.0 but since the Vue-Cli generates the whole process, I wasn't able to figure out where I can add this parameter.
Or is there another solution?
Ok fixed it myself :). Just add this to your Vagrantfile:
config.vm.network :forwarded_port, guest: 8080, host: 80
So nothing to do with Webpack, just basic vagrant setup. This will forward the 8080 port to 80 port of your host machine. So you need to type localhost:80 in your browser to get to your application.

Debug meteorjs application with WebStorm7

I have WebStorm7 installed on a Windows7 machine.
If I run a meteor project in the Windows7 machine with:
>set NODE_OPTIONS=--debug=47977 & meteor
it prints:
=> Meteor server running on: http://localhost:3000/
=> debugger listening on port 47977
and I can debug with WebStorm7 using the_Node.js Remote debug_ configuration, with Host: 127.0.0.1 and Port: 47977.
If I run a meteor project in a Ubuntu machine (within a Oracle VM VirtualBox, with address 192.168.1.9) with:
$ NODE_OPTIONS="--debug=47977" meteor
it prints only:
=> Meteor server running on: http://localhost:3000/
and I cannot debug with WebStorm from the Windows7 machine using the Node.js Remote debug configuration, with Host: 192.168.1.9 and Port: 47977.
From the ubuntu machine a telnet 127.0.0.1 47977 does not work too. It looks like the debugger is not started at all. What am I doing wrong?
the issue might be related to the fact that node.js debugging is only listening on localhost, so you can't connect to the used port from remote host. The workaround is to use a proxy (see http://delog.wordpress.com/2011/04/08/a-simple-tcp-proxy-in-node-js/, for example)
This proxy can be used as follows:
$: node tcpproxy.js 8585 127.0.0.1 5858
8585 here is the 'exposed' port that webstorm will connect to (you can make this what you wish). You are directing traffic that is coming in on 8585 to 5858 (the local debugging port). Ensure 8585 is open on your firewall if you have one. You have to specify this 'exposed' port in your Remote Debug run configuration as a debug port

Resources