External access to home Rails server - ruby-on-rails

My home server is running on Raspberry Pi with Rasbian (Debian for ARM)
There rails server is running: rvmsudo rails s -b ${LOCAL_IP} -p 80
It works perfectly fine to access from local machines, but it is not working when I am trying to access from outside of my local network
It should not be a router problem as I can easily access that server over ssh (both :22 and :80 are open in router preferences)

If you can access http via your local network ip, then it can be issue with router, look to port forwarding settings of DMZ.
BTW, router can use 80 port for its own purposes, like web interface. Try to bind to 8080 port for example.
As an alternative to share 80 port via internet you can use https://ngrok.com/
It allows you to share localhost http to anyone.

Related

How send POST request to a localhost from mobile device?

I'm trying to implement a login in react native + flask app. I have a docker container for my server API. I've run it on my localhost in my computer. I'm also running my front-end on expo. Since it's a different host, how can i send POST request from my mobile device (expo) to the server running on localhost in my computer?
Docker server runs in port 5000 in container. I've mapped the local port 5000 to container's 5000 port.
First of all I hope you are exposing the correct server ports in the docker container.
Then, it can be easily done by using you local machine IP address in your home network instead of "localhost". Maybe your Firewall settings must be changed.
For React I usually save the server IP in an .env, so for production I can easily switch the server

How can I access my local development server over the internet?

I have Wamp 3.1.7 running on a Windows 10 machine. The goal is to have the projects on this server accessible via the internet.
The server is available and working as expected over LAN when accessed with the LAN IP, e.g.
http://10.0.0.3/.
The server runs behind my router, which has its web interface running on port 80, so when I access my public IP, traffic on port 80 goes to the router login page.
Steps taken to try and solve the issue:
change the port my server is listening to from 80 to 8080. (this is working, both locally and over LAN, accessed with http://10.0.0.3:8080)
Add inbound rules on windows firewall for port 8080, set to allow all.
Add port forwarding on the router settings (forward incoming traffic on port 8080 to local IP 10.0.0.3:8080 as per https://portforward.com/d-link/dsl-g2562dg/)
Using PFPortChecker, it says that port 8080 on public_ip is open and able to send data.
I remain unable to access my server. When I go to public_ip:8080, I get ERR_CONNECTION_TIMED_OUT.
As stated above, going to public_ip just displays the router login page.
So as far as I can tell: port 8080 is open, my server is accessible over LAN on port 8080.
What am I missing? Where else could my traffic be blocked?
Stupid mistake on my side.
Answer found here: Public IP Web Page "Connection Timed Out" When Connected To
The issue was that you cannot access the server with the public_ip if connected the LAN the server is running on.

No access to a rails server running behind a firewall

I am trying to run a ror application at a friend's home and the application is not reachable from the outside. Here is what we have tried.
The application has been created with
$ rails new <application name>
and started with
$ rails server
The development server starts and is reachable on http://localhost:3000
Next thing we have activated port forwarding on the router he uses to connect to the internet: we have mapped the external port 3000 to port 3000 on the internal host on which the rails server is running. When I try to open the page from the outside (with firefox) I get an error page: unable to conenct to host, the host may be down, try to connect later.
Things we have tried:
Changed port forwarding 80 -> 80
Installed and started Apache: the default Apache page is reachable.
Stopped Apache and started the rails server on port 80 (with sudo, otherwise it can't use port 80): the rails server is not reachable.
I have also checked the firewall of the machine running the rails server. The OS is ubuntu 12.04: the firewall (at least ufw) is not active. I can also connect to that machine using port 22 / ssh.
Summarizing:
rails server is accessible on port 3000 on local host
port forwarding works for ports 22 and 80 and both ssh server and apache server are reachable
rails server is NOT reachable on both port 80 and 3000 from the outside
The only thing I can think of is that rails might have a mechanism similar to Django's ALLOWED_HOSTS and that it refuses external requests because they are for a different host than localhost. However, I haven't found anything on this topic. Also, the application's log files do not show any connection attempt that was refused by the rails server.
So we are out of ideas. What should we check next?
Prior to Rails 4.2, the default for rails server was to bind to all interfaces. In Rails 4.2 this changed to only bind to 127.0.0.1 by default - there's nothing in the application logs because the socket is simply not listening to connection on other network interfaces.
To allow connections from another machine you need to use the -b option to bind to extra ip addresses, eg
rails s -b 0.0.0.0
to bind to all available ip addresses. You can of course replace 0.0.0.0 with one of your machine's actual ip addresses although you would of course have to change that invocation whenever your machine's ip address changed.

Access Webrick Rails Server from local network

Hello i am trying to access my Webrick rails server that i started on my ubuntu to my windows 7 pc locally. I checked on ifconfig in my virtual box and used the inet:10.0.2.15 when i run my rails server and also used port 80 like this:
rails server -b 10.0.2.15 -p 80
It didn't gave me an error in the terminal but when i try to go to 10.0.2.15 on my windows browser, it says it can't connect. I tried disabling the firewall in windows but still wont work. Thank you.
Choose another network type for your VM ubuntu. I suggest the Bridged Network. Reboot vm, it should obtain ip in same network as your windows host (example 192.168.0.XXX). Then you will be able reach your rails server from network At any port 80 or 3000.
Can you share your ubuntu with the vm, via the apache server too? is that started? In macs you have to enable web sharing (or something similar to that wording). ON ubuntu what happens when you do localhost:80... if i recall it should say it works! or something like that.

Rails server won't respond to any request outside the local network

I'm running Rails con a VM with a bridged interface, it has it's own IP in the local network.
When I start rails in 0.0.0.0:3000 I can access it using the local network IP in the port 3000 without any problem.
The router NAT configuration is to route the port 3000 to the VM.
When I check the port 3000 on http://canyouseeme.org with the Rails server stopped it says the port is closed. With the rails server started it says the port is open. This means, the router is indeed routing to the VM, right?
But when I try to enter the server through my public IP in the port 3000, it won't answer.
I tried changing the server from Thin to Webrick, with the same result.
Also, I tried to run another web server in the port 3000 with he same results. No answer to public requests outside the local network. Yet the port is checked as opened.
Also, UFW is stopped, and anyway I allowed the port 3000.
Any ideas?
Some routers don't support loopback, meaning you can't access the public IP from within the LAN. FWIW, I tried this"
telnet canyouseeme.org 3000
Trying 8.23.224.110...
With no luck.

Resources