Access Rails App Subdomains Through VirtualBox - ruby-on-rails

I'm running a Windows 7 VirtualBox on my Ubuntu 13.10 machine where I have my rails app. I access my rails app through subdomains (i.e. subdomain1.lvh.me:3000) and I'm trying to access these same subdomains through my VB. I've read to change the host file but I haven't been able to make it work. Would I be using the Gateway IP or the IPv4 address?
The reason for me trying to accomplish this is to develop on my Ubuntu machine and test for IE issues on my VB without using paid third party websites to render my changes.

I think that if, for example, your ubuntu machine's ip address is 192.168.0.123, then it should suffice to have this line in your windows hosts file
192.168.0.123 subdomain1.lvh.me subdomain2.lvh.me subdomain3.lvh.me
Then on your windows vb you would access subdomain1.lvh.me:3000 like you say.
Have you done this? I don't know what you mean by " I've read to change the host file but I haven't been able to make it work. " What isn't working?

Related

How to access rails server in a remote VM

I set up a Virtual Machine (VM) on OpenStack remotely. The VM is running Red Hat Enterprise Linux (RHEL) 7.
I ssh into the above VM using ssh vm-url, and then I setup a rails server during that ssh session and get it running using rails server -b vm-url
Now, I try to access the rails website above from my local Chrome browser by typing the URL vm-url:3000 into Chrome's address bar (the Omnibox), but I get:
This site can’t be reached
10.150.8.101 took too long to respond.
Why Can't I access the rails website, what have I done wrong?
Please correct me if any terminologies I used are incorrect.
Thank you.
Two things to check,
The ip attached to the VM is public and accessible
Http port is enabled to be accessed from outside
The port accessed is handled in security groups which is generally configured while creating the instance. Either add new security group with enough privileges or update the same with new added ports.

Accessing rails sever on a virtual machine from host machine

I've got Ubuntu (the newest version) running as a virtual machine on Windows 7 Pro, using VMware.
My question is, can I make the rails sever acessible to windows while the virtual machine is running?
So, for example, if I type on my Windows browser http://localhost:3000 I would get the rails sever?
Also, can I make it acessible to computers from the outside, so if someone would type
myipaddress:3000 he would be able to acess the sever as a client?
I hope this is clear.
There are a lot of "ifs" here, but it should "just work".
In Linux, find the IP address of your virtual machine.
$ /sbin/ifconfig
You're looking for a section that is probably labelled "eth0" and in that "inet addr".
Using that address with port 3000 from your Windows host should work fine. If not, post the specific problem that you're seeing, including any logs you can find or info on any firewalls you have running on your Linux client.

Can't view Rails app on Windows7 via mac local address

My app runs on localhost:3000 on my mac
My mac has its own local address eee.local
Other computers in the office, including other windows machines
can connect to eee.local:3000 and use the the rails app.
However we had once case where one person's windows7 machine
could not connect. I brought a brand new windows7 machine for
IE testing purposes and it doesn't connect either.
I tried turning of the firewall and that doesn't work.
I tried using the ip instead eg. 192.160.0.3:3000 but that doesn't work.
I'm not really sure how else to check, or search for this problem
Anything Im overlooking?
Another thing to try is to install iTunes. Sounds silly at first but installing iTunes gives your Windows machine Bonjour service discovery (enabled by default on Macs and Ubuntu desktops) which would let you resolve .local addresses.
Accessing via the IP really should have worked but if you've already turned off firewalls and the machines are on the same network then enabling Bonjour (by installing iTunes) is worth a shot.
Is the other Windows machine on a different subnet? That could cause the issue.
You need to tell the web server to listen on all interfaces like so:
./script/server 0.0.0.0:3000

Remotely viewing web pages served by pow.cx

Using WEBrick you could navigate to an app you were serving from another device/virtual machine by navigating to your.ip.address.here:port
Is it possible to do something similar with pow.cx?
The latest version of Pow (0.4.0) now includes xip.io support. You can read about the release here.
Here's a quick explanation of how this helps Pow serve your Rails apps across your entire local network, from their post:
Say your development computer’s LAN IP address is 10.0.0.1. With the
new version of Pow, you can now access your app at
http://myapp.10.0.0.1.xip.io/. And xip.io supports wildcard DNS, so
any and all subdomains of 10.0.0.1.xip.io resolve too.
Here's a description of xip.io, from their site:
xip.io runs a custom DNS server on the public Internet. When your
computer looks up a xip.io domain, the xip.io DNS server extracts the
IP address from the domain and sends it back in the response.
There are basically two options:
Don't use pow: run your applications on localhost as usual and access them as usual
Edit the hosts file (or local DNS) to point your server machine ip
Example accessing from a virtual windows machine:
Suppose you are running two rails applications in pow: store.dev and auth.dev, and you want to access them from a windows xp virtual machine to test them with IE, you only need to edit your hosts file to add the lines:
C:\WINDOWS\system32\drivers\etc\hosts
# Allow to access applications in pow.
# The ip address points to the host machine localhost, that usually is the default gateway
10.0.2.2 store.dev
10.0.2.2 auth.dev
And then open the IE browser to access your applications in http://store.dev and http://auth.dev respectivelly.
Specifically, no, because Pow uses the Host header of the request to determine which app you need to access. To get that working remotely, you would have to have the remote machine map the required domain name to your IP address - either with a local DNS server or by editing the HOSTS file. Both of which are possible but annoying.
The simplest thing to do in that case is to start up a standalone Rails server as you mentioned (using ./script/server or rails s depending on the version), and then you can address http://[ip address]:3000 as before.
In other words, Pow works because it intercepts your local domain resolution, something that isn't affected by (or available to) remote machines.

How do I access my web application from a non-local machine?

I have a Ruby on Rails application that I'm developing on my computer, which runs Ubuntu 10.04 LTS. I'd like to be able to access it from a remote computer for testing purposes. I've no idea how to proceed. Do I need to set up port forwarding? Virtual hosts? Can anyone point me to an article/tutorial/whatever that has information about how to do this?
Thanks!
If you want to run it using the server script, you can have it listen to a specific IP address like:
script/server -b 192.168.1.5
Substitute your machine's IP address that is accessible over your network. Then other hosts can get to the Rails app via e.g. http://192.168.1.5:3000.
If you mean you're behind a firewall or NAT gateway, then the question of how people outside of your firewall/NAT can get to your machine is another question entirely... something that probably belongs on superuser.com.
The best way I've found is to use http://www.tunnlr.com.

Resources