N
N
Nikolay2015-07-23 20:54:17
Ruby on Rails
Nikolay, 2015-07-23 20:54:17

Does not connect to the site through the ip of the computer to the network?

Good afternoon.
Please tell me what should be done, how to solve the following problem?
I'm sorry, as I'm new to this, so the terms may be confused in my explanation, or maybe the question is stupid. But I haven't found an answer yet.
Installed ubuntu amd64 OS on the virtual machine from the provider. Set up Ruby on Rails and create a test application ( rails new test ).
Launched a test application with a command line: rails s -d .
But by the ip address of the machine from home I can not connect to the site.
Since there is no GUI (access from the command line only to the machine), I ran the following commands on the virtual machine: curl 127.0.0.1:3000 - got the page.
Teams:curl localhost:3000 and curl 0.0.0.0:3000 also pass - I get a page of a test running application. I run curl 182.8.8.8:3000
( machine ip address) and get an error: curl: (7) Failed connect to localhost 182.8.8.8 port 3000: Connection refused That is, the Webrick web server turns out to accept connections from localhost, but 182.8.8.8 is needed. Tell me, please, where to dig, what to fix? Added: Made more firewall rules:

iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT

Perhaps I didn’t do it very correctly, but I understood it from the iptables documentation.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yueeucrl, 2015-07-23
@M0zart

try rails s -b 0.0.0.0

R
Roman Mirilaczvili, 2015-07-24
@2ord

If you need to connect via the Internet to a remote machine running a web server, then there are 2 options: one is suitable for production mode (RAILS_ENV=production), the other is for development (RAILS_ENV=development). Both options assume that the web application has been pre-debugged or at least able to run without errors. They are not suitable for development.
1. Suppose you need to quickly show the preliminary results of the site during development.
Then it's easiest to use the ngrok service .
For Ubuntu, you need to install the ngrok-client package . The version of the package for Ubuntu 14.04 was installed for me without problems on the earlier one, 12.04.
After starting the web server (port 3000 for Webrick), then run a command
that will run in output mode to stdout. You can terminate the session with Ctrl-C.
When run, it will show the URL by which you can access the local machine. Something like
3e7ddc7.ngrok.com
Check with any HTTP client like this:
From a remote machine via a web browser or command line
But for the sake of the server host's security, I wouldn't leave the ngrok session for long.
2. When everything is debugged and put on stream, you need to integrate the application on the server. Usually used nginx/Apache as front + Unicorn/Passenger as backend.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question