How to run Jekyll on a virtual box server? - vagrant

I'm on a Windows 7 x64 machine with Virtual Box and Vagrant installed. I installed
Ruby
Rubygems
correctly and installed jekyll. The final message I received on my PuTTY terminal is :
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
When I visit the url on Windows Chrome browser, it says
This site can’t be reached
127.0.0.1 refused to connect.
What are the extra configurations that needs to be done so that Jekyll can run on the virtual box server?

To access the jekyll instance in the virtual box server, run Jekyll with the server IP.
Usage:
jekyll serve [options]
Options:
-H, --host [HOST] Host to bind to
Supposing the virtual server IP is 192.168.1.100 then run the following command in the server to make the jekyll instance accesible from outside:
jekyll serve -H 192.168.1.100
Then it will be accessible at http://192.168.1.100:4000

If you dont use a static IP as mentioned in the other OP, you need to forward the port where jekyll will run
In your Vagrantfile
config.vm.network :public_network
config.vm.network :forwarded_port, guest: 4000, host: 4000,
You will start jekyll using the command
jekyll serve --host 0.0.0.0
Then you could access your site from http://localhost:4000/ from your host machine

Related

Cannot access application running on JBOSS EAP 7 outside vagrant box

I am actually trying to access the application outside the vagrant box which is running on JBOSS EAP 7 server on port 8080. I did add the settings for port forwarding in vagrant file that is
config.vm.network :forwarded_port, guest: 3000, host: 8080
Port forwarding does shows in terminal log when i reloaded the vagrant. However when i access the application from browser outside of the vagrant box am getting error as ERR_CONNECTION_REFUSED on the browser. I also binded the address to 0.0.0.0 by running the below command but still no luck. Any suggestions please what i may be missing? I also did set the proxy settings but still no luck.
sudo ./standalone.sh -b 0.0.0.0
Below is the port binded with 0.0.0.0
Below is the log for my vagrant reload
Below is the port forwarding i set in my ubuntu vagrant box
Below is the error on the browser
I found something that could help.
I'm using a RHEL 7.6 and the firewall was on:
$ sudo firewall-cmd --state
running
After disabling:
$ systemctl stop firewalld
$ sudo firewall-cmd --state
not running
I successfully access Jboss console from the outside

Vagrant Jekyll serve not available

I decided to try Jekyll, but as I have not used it I encountered a problem. When i serve it i get "This webpage is not available" on http://127.0.0.1:4000/. I'm using vagrant.
vagrant#ruby-jekyll-box:~$ jekyll new portfolio
New jekyll site installed in /home/vagrant/portfolio.
vagrant#ruby-jekyll-box:~$ cd portfolio/
vagrant#ruby-jekyll-box:~/portfolio$ jekyll serve
Configuration file: /home/vagrant/portfolio/_config.yml
Source: /home/vagrant/portfolio
Destination: /home/vagrant/portfolio/_site
Generating...
done.
Auto-regeneration: enabled for '/home/vagrant/portfolio'
Configuration file: /home/vagrant/portfolio/_config.yml
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
What am I doing wrong?
are you trying to access it from inside the vagrant box? or from the computer you are running the vm on? 127.0.0.1 is localhost/loopback so 127.0.0.1 inside the vagrant box is not the same 127.0.0.1 on your computer.
try
jekyll serve --host=0.0.0.0
and then accessing it from your host computer at http://ip.of.vagrant.box:4000/

Can't access Ruby server on VM from host machine

I have a VM set up running Ubuntu server 14.04. In my VM I have created the following Ruby/Sinatra app:
require 'sinatra'
set :environment, :production
set :bind, '0.0.0.0'
get '/' do
"Hello World!"
end
When I execute this using ruby hello.rb I get the following output:
[2015-03-09 16:58:34] INFO WEBrick 1.3.1
[2015-03-09 16:58:34] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
== Sinatra/1.4.5 has taken the stage on 4567 for production with backup from WEBrick
[2015-03-09 16:58:34] INFO WEBrick::HTTPServer#start: pid=2258 port=4567
Everything seems to work fine, but when I try to access localhost:4567 from my host machine (Windows 8.1) I get a GET http://localhost:4567/ net::ERR_CONNECTION_REFUSED error (in Chrome).
If I try to access the server from within my VM (ex, by using wget http://localhost:4567) it works fine.
I also have Apache2.4 running in my VM, which works fine, but I disabled it when trying to access my Ruby server by running sudo service apache2 stop.
What could the problem be? I have no problem running regular Ruby files, and I can access my Ruby/Sinatra app if I use Apache2 with Phusion Passenger. But when I simply run ruby hello.rb I can't access it from my host machine.
localhost refers to your local host, which in the case of Windows is not the same as your Ubuntu instance.
You'll need to connect to your Ubuntu instance IP directly, whatever that is. Usually you can find out with ip addr or ifconfig.
If you need a friendly DNS name you can put in your browser, xip.io provides one.
If you're using Vagrant then you can configure port forwarding so you can still use localhost if you want. Without port forwarding you will not be able to connect indirectly.
I have the network adapter for my VM attached to NAT. I was forwarding ports 443, 22 and 80 to my VM, and accessing my server on those ports works fine. Since I was running the Ruby WEBrick server on the default port 4567, I just had to forward port 4567 from my host machine to my VM as well.
After that change, typing http://localhost:4567 into my web browser served up the content from my Ruby file.

Empty reply from server - can't connect to vagrant vm w/port forwarding

I'm running werkzeug (as part of a Tilestache setup) inside a Vagrant VM, running ubuntu 'precise.'
In my Vagrantfile, I have:
config.vm.network :forwarded_port, guest: 8080, host: 8080
When I start the server in the VM, I see:
* Running on http://127.0.0.1:8080/
If I curl that address from within the VM, I get the expected result. When I curl it from the host machine, I get:
curl: (52) Empty reply from server
And Chrome says "No data received."
Troubleshooting info:
The server responds to pings from the host machine
a port sniffer verifies that the port is open
running netstat -ntlp | grep 8080 in the vm shows that the server is listening on 8080
My local hostsfile doesn't have any weird conflicts
I'm also forwarding 22 => 2222, and I can ssh in with no trouble
I've disabled the firewall on the host, and i don't believe there's one on the guest (iptables and ufw are disabled, at least)
I've set auto_correct: true in case there are conflicts (there aren't)
I know I could set up a private network, but I'd like to understand why this isn't working and how to troubleshoot it.
Any other ideas?
When running a server from within a VM, start the server on 0.0.0.0 instead of 127.0.0.1.
127.0.0.1 is only accessible to the local machine, which for a VM means nothing outside of the VM can reach it! 0.0.0.0 is accessible from anywhere on the local network, which to a VM includes the host machine.
The answer came from here: Connection Reset when port forwarding with Vagrant
(Which apparently got its answer from here: https://stackoverflow.com/a/5999945/738675)
With help from: https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1
Google-bait:
Here are the errors you might receive if this is the problem:
Chrome: "No data received"
Firefox: "The connection was reset - The connection to the server was reset while the page was loading."
Safari: "Safari can’t open the page [URL] because the server unexpectedly dropped the connection"
curl: "Empty reply from server"
In the /etc/hosts inside the VM, change line
127.0.0.1 localhost -> 0.0.0.0 localhost
and then restart server
This can also be a problem with your firewall on the vagrant machine. If you can curl the address while on the vagrant box, then check your firewalld settings or turn it off:
on CENTOS:
sudo service firewalld stop
Then you should update your firewalld settings and restart it ;)

Vagrant port forwarding not working on Mavericks

I'm using a vagrant Geodjango box and port forwarding is not working for me.
On the box, I have run:
python manage.py runserver 0.0.0.0:8000
But http://localhost:8000 and http://localhost:4567 both find nothing on the host machine.
On the Vagrant box, curl -v 'http://localhost:8000/' gives the usual:
<h2>Congratulations on your first Django-powered page.</h2>
which suggests that Django is running okay. But on the host machine, trying curl -v 'http://localhost:8000/' gives the following output:
curl: (7) Failed connect to localhost:8000; Connection refused
My Vagrantfile has the following port forwarding set up:
config.vm.forward_port 8000, 4567
Disabling the Mac's firewall does not help and stopping Apache makes no difference. I have tried running lsof -i :8000 on the host machine and there is no output, so I figure nothing is using the port.
Can anyone suggest anything?
I had the same issue on Yosemite and none of the ports were forwarding. Disabling the Firewall filter on the guest machine helped:
sudo service iptables stop
Good to see you figured it out yourself.
Just want to add my 2 cents, in V2 Vagrantfile, the port forwarding code block is like below, try to use the new ones so as to avoid port conflicts (back in v1 I always got confused which is which).
config.vm.forward_port 8000, 4567 is forwarding guest port 8000 to host 4567, not the other way around.
In V2 format, it looks like below, which is clearer from my opinion
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end

Resources