Routing to rails server from local IP - ruby-on-rails

I have a rails app running on standard port 3000. I can access it from localhost:3000 just fine, but I want to access it from my LAN address as well. (http://192.168.1.x:3000). When I try to use the LAN IP in my browser, I get a connection refused error. I am using POW (http://pow.cx/), which may be the culprit, but cannot sort how. I CAN access http://192.168.1.x which delivers the default pow landing page, so it seems like the IP resolution is working, but for some reason not on the port my app is serving on.

Related

Ruby on Rails - Starting server as a live website. [Linode]

I have made an account on Linode website and have a "linode" running. I have a server running using ruby on rails. The command I used is the following:
rails server --binding=<ip_adress>
The server starts up without issue. The question I have is why can't I visit the the side I created using my browser, just by putting the ip_address in the browser? The server logs display the following
Environment: development Listening on tcp:<ip_address>:3000
I can visit this ip_address on my browser but I need to add the ":3000" in the browser so I can view the site.
Shouldn't I be able to just visit the stand alone ip_address without entering ":3000"? I also wanted to say I am just learning ruby on rails as well.
I haven't tried anything more than described above
An IP address is a way to identify a machine on the internet.A port is a number assigned to uniquely identify a connection endpoint and to direct data to a specific service.
Therefore, your rails service is a combination of an IP address and a Port number. Since you can have different services running on the same machine at the same IP address.
HTTP has a default port of 80 which is what your browser will try to access when you don't provide a port.
Most likely, you will want a Reverse Proxy hosted at port 80 that forwards traffic to your rails app.
This post provides a better answer of how this works. https://superuser.com/questions/394078/how-can-i-map-a-domain-name-to-an-ip-address-and-port
Not Recommended
If you don't want to use a reverse proxy, you can host the rails server at port 80 itself.
rails server -p 80
Note that this requires you to have root permissions on the machine.

Is there a way to get the iOS simulator to access a FQDN redirecting to my localhost?

I am running a local web server with SSL enabled that my app needs to log into. I have a domain name whose A-record is set to 127.0.0.1, which allows for local development using loopback with an nginx server with different subdomain configurations for services on the app I have hosted locally. The problem is that, in the iOS simulator, the domain resolves to the device's localhost and not my machine. I can't use the IP address of my machine because I need the domain for nginx to redirect to the proper vhost (also SSL and OAUTH would get mad).
Is there any way to use a custom DNS server for lookup in the simulator? Either that, or can I edit the hosts file to set the domain to my device's LAN IP instead of localhost? Any other ideas?

I cant access my server rails app

Well as the title says i cant access my ruby on rails app, on the server i run the command:
rails s
After that everything works like it is suppose to work but it doesn't
When I enter my ip on my browser i put it like this x.x.x.x:3000 I have also tried x.x.x.x:3000/andtheurls
On my server i have run the command:
nmap localhost
To see if the port 3000 is opened, and it is.
My browser just tells me that it cant access the site and that my conexion has been rejected
I use and ubuntu 14.04 for my server
Not sure what IP address you're trying to use, but the easiest way is just to type localhost:3000 in your url bar.
By the way, this is the same as 127.0.0.1:3000. You should realize that this isn't your actual public IP address, though. Everyone's local IP address is 127.0.0.1: it is the loopback's interface address.

why I am not able to access rails localhost on my mobile or other computer

I am trying to access my localhost of rails running project on my mobile device.
This is how I am trying.
http://ip:3000
But it says the webpage is not available.
I tried with another port as well and It doesn't work even there?
What's wrong here? I use to check earlier this way.
Please guide
Try running this code below to your server:
rails s -b 0.0.0.0
This worked for me!
Just give:
ip = your phone's ip address
(Check it in connection information if you are running this on Ubuntu)
ip:3000/your_page if you do not have mapped your root to some page.
Else ip:3000 will work if you have mapped root to some page.
Try it in Chrome and see as it doesn't need any http or https it automatically selects the required one.
Here is how I did it
Put both your computer and phone on the same wifi network
rails s -b 0.0.0.0
routerlogin.net (or however you access your router it will say on the back of router)
get attached devices to the router. Note your computers ip. Mine was 10.0.0.20
on phone go to 10.0.0.20:3000 (but use the ip for your computer from step 4)

Accessing Ruby Server on amazon instance from my browser

I have started the Ruby on Rails tutorial and am on my first app. I did all of this on an instance I have on amazon web service (aws). A while ago I installed apache on there so when I put in the public address (port 80) it tells me 'It works'. I want to access this server from my web browser at home.
However when I put in the server address :3000 (the port the app should be running at) I get nothing. Do I need to tell the box to open port 3000 or something of the like?
You need to open the instance's security group to accept traffic on port 3000. Check out the docs for more information.

Resources