How to connect rails application(locally run on zeus) in another machine using IP? - ruby-on-rails

I am using two rails applications, running both with rails s and zeus s -p3001 locally. When I am trying to run my application in another machine, the server started with webbrick is running fine on another system but couldnot run zeus. PLease help me out.
I just gave the url in browser 192.168.1.111:3000 (running). And
`192.168.1.111:3001` (server not found).
I tried zeus s -b 192.168.1.111:3001 but didn't help me.

The problem is, that the zeus bind to the local address (127.0.0.1) prohibiting connections from remove hosts. The proper solution would be to setup the reverse proxy using apache2 or nginx.
http://glasz.org/2013/10/25/reverse-proxy-a-rails-app.html
https://www.digitalocean.com/community/tutorials/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5
Alternatively you may also want to use firewall to redirect requests.
http://forum.slicehost.com/index.php?p=/discussion/2497/iptables-redirect-port-80-to-port-8080/p1
But a quick and dirty solution is to use SSH port forwarding like this:
Start zeus on remote machine on port 3000
On local machine
local-machine$ ssh -L 3001:localhost:3000 remote-machine
On local machine: Connect to localhost:3001 instead of to remote-machine:3000
http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html

Related

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

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.

How to access Rails WEBrick running on a VPS

I'm fairly new to Rails and VPS. I created a SSH tunnel and managed to install Ruby/Rails, then I created a simple scaffolding app to play around. One question now coming up is, how I can access the running WEBrick server via my browser? I tried the IP of my VPS and added XXX.XXX.XXX.XX:3000 as the port. But for some reason it does not work. Any idea? Thanks
Try port 80 as 3000 can be quite sensitive to firewalls and certain ISP's

Domain setting using ruby rails

I am planning to have a web application.
To do so, I studied about ruby and ruby on rails. I am using linux server from amazon clouding system.
I bought a domain from godday, and I put the IP address on DNS setting. When I run 'rails s' command, I can connect to the wep page through port 3000 in such a way that domain.com:3000. However, I cannot directly connect to domain.com. How can I my domain works without port 3000?
And Do I have to run 'rails s' every time to make the wep page work? Actually I tried to use 'rails s &' to make it run in background. But it fails. How can I make the server run even though I am not connected to the linux server?
Thank you!
usually you use rails s just in development. there are quite a few ruby web servers you can choose from for your production environment: puma, passenger or unicorn to name a few.
of course all of them have their own tutorials how to set them up. for starters, i'd go with with passenger because it's integrated with nginx and apache and easily set up.
You need to specify a port, if you don't see the port it can be either 80 (http) or 443 (https).
rails server -p 80
On linux you have to be root to bind to port less than 1000, so just append sudo in front.

Cannot access http://localhost:3000

I am trying to learn Ruby on Rails, I have followed the instructions from this page to get rails installed on my PC.
I am also trying to follow this webcast to try and learn the language and framework. Everything is working so far, apart from the fact that I cannot access
http://localhost:3000
http://0.0.0.0:3000
http://127.0.0.1:3000, or
http://<actual IP address>:3000
locally. If I try the from another PC on my network then it works great. I have tried in Chrome, Firefox and IE7 but none work.
Has anyone else had this problem?
EDIT: Typical!! It's started working now. I have no idea why, I am typing the exact same address in to the address bar and it now works. But only if I use http://127.0.0.1:3000, localhost doesn't work. I do run IIS ASP.NET/ASP websites on this machine, and they work fine with localhost.
EDIT 2: If I trying pinging localhost it actually says
Reply from ::1: time<1ms
0.0.0.0 yields...
PING: transmit failed, error code 1214
only 127.0.0.1 seems to work. I did have IPv6 turned on, so I've disabled that and will try again tomorrow to see if a reboot helps.
I had this issue as well with Vagrant. The secret is to run
bin/rails server -b 0.0.0.0
What 0.0.0.0 means is to listen to all interfaces, not just on localhost. The alternative is to SSH into the vagrant machine with a SOCKS proxy.
ssh -C -D 8080 vagrant#localhost
Open up your Internet explorer proxy settings and set the SOCKS v5 proxy to port 8080.
In order to access http://localhost:3000 you need to run the local Rails server in a terminal window:
$ rails server
This is described in this section of the Rails Tutorial book.
Note: I am the presenter of the screencasts in question.
Can you telnet to the port? Try:
telnet localhost 3000
That should tell you if the ports unavailable at the TCP level, or whether something's going on at the HTTP level.
Ping might not work if ICMP is disabled, which could be completely unrelated to your issue.
Also, try looking in your hosts file for any redirections:
c:\Windows\System32\drivers\etc\hosts
One way is to do the simple
rails s
Another (more specifically) is
rails start localhost 0.0.0.0
or
rails start 0.0.0.0
another way is
rails s 0.0.0.0
all of these works
I had an epic issue with my System Path (Environmental Variable) not being set properly.
Simple copy paste job, unplugged the 1 week stalled Ruby installation.
Control Panel > System > Advanced tab > Environment Variables > System variables > Path... Edit...
Make sure it contains these paths (among others)...
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
I had your same identical problem. You have simply to run
$ rails server
from inside the folder of your application, not outside...so, if you have your application in
C:\Sites\myapp\blog
and blog is the folder where live your app, the command has to be prompted from here. Launching it from myapp folder won't work.
Are you possibly using a proxy but haven't listed localhost as proxy exception?
Have you tried disabling your firewall? They can cause pesky problems at times.

Resources