Accessing rails application from another computer which is on different network - ruby-on-rails

Can I acces my rails application which is running with rails s right now from another network?
I am using a dynamic IP address, and if I just go to http://whatismyipaddress.com/ and enter the IP provided there into the browser and end it with :3000, it will give a unable to connect error.

There's a gem called localtunnel. The easiest way to share localhost web servers to the rest of the world.
$ gem install localtunnel
$ localtunnel -k ~/.ssh/id_rsa.pub 3000
You should see something like this:
Port 3000 is now publicly accessible from http://8bv2.localtunnel.com ...

Related

Serving localhost rails application externally https

I am currently running a rails application on my local machine as the backend api for a hobby web application (have too many sql rows and dont want to pay for it).
I already figured out how to forward my port and access the api through http://[myexternalipaddress]:8080/api/etc.... from the external internet.
This is working fine, but i want to be able to serve this end point through https instead so my users dont get security warnings. I did some research, but I am confused what I need to do next. Is the https serving done via my rails configuration, or some other method?
here is the command I use to start my rails server:
rails s --binding=0.0.0.0 -p 8080
You can use ngrok and expose your local server
on mac you can install it with brew
$ brew cask install ngrok
$ ngrok http 3000
this will give you url like https://xxyyzz.ngrok.io to access it publicly

how to make foreman port accessible from outside in mac

I have a rails application that use foreman to serve on localhost:3001.
I turned off the whole firewall but still it's not accessible from out side.
How can I share this port to the network?
You cannot access the development mode rails server from another computer(remote access).You need to bind the server to the ip like this:
rails s -b 111.11.11.111 // 111.11.11.111 is an example for ip address

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.

How to Deploy Rails App to AWS

I am trying to host a Rails app in AWS cloud where I have an EC2 instance and apache and mysql . Here I have uploaded my app but I am unable to bind it with IP. For a testing I am using this blog post https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04 as a reference .
When I am trying to run this command :
RAILS_ENV=production rails server --binding=server_public_IP
I am getting this error :
/home/ubuntu/.rbenv/versions/2.2.3/lib/ruby/2.2.0/socket.rb:206:in `bind': Cannot assign requested address - bind(2) for 52.24.103.139:3000 (Errno::EADDRNOTAVAIL)
Is there anyone help me understand what is this problem and how to deploy it on AWS apache .
In AWS the machine is not directly assigned the IP, i.e. it is routed using NAT. hence you can not use the public IP to start your rails server directly.
To start server just boot it without the binding parameter rails s production
Or you can use 0.0.0.0 to bind your server, this will start your rails on all the interfaces.
Tip: For production you should ideally server using some web server like nginx/apache using passenger/unicorn
Looking from error it says it cannot bind with ipadd 52.24.103.139:3000
What I would suggest it to open a 'custom TCP port 3000' and try running the same thing again.
May be your app is working on port 3000 not 80.
Hope that helps.

After installing rails, how to run rails server on amazon ec2 instance?

I installed rails on an instance on amazon AMI. I installed all the dependencies for rails. I even copied the code through scp. When i ssh to the instance i ran
rails s
The server is running. How can I view it from the browser?
from the Public DNS???
In summary, sure that your security group have a rule for TCP 3000.Then, you can use the Public DNS:
rails server -b ec2-XX-XX-XX-XX.us-west-2.compute.amazonaws.com -p 3000
And access to: ec2-XX-XX-XX-XX.us-west-2.compute.amazonaws.com:3000
This works for me.
Your amazon ec2 instance has a public ip address and domain name, see
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html
use this domain name as the URL in your browser.
You will also have to set inbound traffic / port connections in the security group of the instance.
A word of warning: with "rails s" you are starting webrick, a server that is only meant to be used in development. You probably should use a production server like apache + mod_passenger.
For more advanced usage of ec2 and ruby on rails see
http://railscasts.com/episodes/347-rubber-and-amazon-ec2?view=asciicast
move to folder from rails aplication and typerails s -b 0.0.0.0

Resources