VirtualBox port forwarding method for Jekyll Windows testing
In my case, I build and test Jekyll(GitHub Pages) on an Ubuntu VM in Virtual Box, then push it to GitHub. However, the look and feel of browsers such as Firefox in an Ubuntu VM are slightly different from the look and feel of an actual X86 Windows. So, I would like to explain the Virtual Box port forwarding method to test Jekyll on the X86 Windows browser.
Running Jekyll locally on Ubuntu VM
First, check the IP address of the network interface using ifconfig
in the Ubuntu VM. In my case, the IP address is 10.0.2.15
.
1
2
3
4
5
6
7
8
9
10
11
$ ifconfig
..
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::e1f0:30d0:1e9b:bafc prefixlen 64 scopeid 0x20<link>
ether 08:00:27:07:7a:96 txqueuelen 1000 (Ethernet)
RX packets 9737 bytes 12163823 (12.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3811 bytes 1289032 (1.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...
To test Jekyll, run it and enter the IP address confirmed above with the --host
option.
1
2
3
4
5
6
7
8
9
10
11
$ bundle exec jekyll serve --host 10.0.2.15
Configuration file: /home/myaccount/my_jekyll_root/_config.yml
Theme Config file: /home/myaccount/my_jekyll_root/_config.yml
Source: /home/myaccount/my_jekyll_root
Destination: /home/myaccount/my_jekyll_root/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 1.483 seconds.
Auto-regeneration: enabled for '/home/myaccount/my_jekyll_root'
Server address: http://10.0.2.15:4000/
Server running... press ctrl-c to stop.
Set up port forwarding for Ubuntu VM in Virtual Box manager
In the network settings of the Ubuntu VM in the Virtual Box manager, add port forwarding by entering the following.
The Guest IP
address is the IP address confirmed on the Ubuntu VM.
- Name : (Name you want)
- Protocol : TCP
- Host IP : 127.0.0.1
- Guest IP : 10.0.2.15 (IP address of the Ubuntu VM confirmed above)
- Guest Port : 4000
VirtualBox Manager - Port Forwarding Rules
Now you can test Jekyll by connecting to 127.0.0.1:4000
in your X86 Windows browser.