Ruby Rails callback URL in development - ruby-on-rails

I am integrating Plivo in to my application(Ruby/Rails) and I would like to setup the router to point to my local dev environment for the callback. I have setup my controller method: plivo/receive_sms and the associated route in routes.rb
My question is: How do I setup my router(NETGEAR) to receive the callback for localhost:3000/plivo/receive_sms from Plivo?
I have tried forwarding port 80 to my local IP (192.168.1.20) But that did not work.. So I added ports 3000 - 8080 with no success.

That should work:
Make sure you are forwarding external port 80 to your local port 3000.
Make sure the Plivo is configured with your OUTGOING public IP address as the call back URL hostname. (google for "What is my ip"? and google will tell you)
If that doesn't work, perhaps your computer is firewalled? Or your router / ISP firewalls port 80?
If #3 is the case, then try forwarding port 3000 to your local port 3000, but then you have to be able to change the callback URL (#2) to use port 3000.
Or - try:
localtunnel.me
localtunnel gem
PageKite
ShowOff
https://pagekite.net/2011-04-20/PageKite_meets_Showoff
http://devblog.avdi.org/2012/04/27/http-forwarding-services-for-local-facebook-development/
Or if you have access to a server thats sits somewhere on the internet, there are gems similar to local tunnel that will use your own server to do the proxying.
Or you can do it manually with SSH using the -R or -L option (I forget which).

Related

Vagrant cant connect to local host

Hello i am having trouble with vagrant setup.
So i am trying to ping serverless API which runs on http://localhost:3000/ (and it's outside vagrant project).
Right now my vagrant project runs on https://localhost:4443/.
Overall trying to CURL request from vagrant project to another serverless project.
Tried to use http://localhost:3000/ in CURL request but getting Failed to connect to localhost port 3000: Connection refused
Tried to use VM ip 10.0.2.15 address same
Tried to do port forwarding in vagrantfile config.vm.network :forwarded_port, guest: 3000, host: 3000 and use machine IP address 192.168.0.16, getting empty response from server, when i try to do telnet 192.168.0.16 3000 getting
Trying 192.168.0.16...
Connected to 192.168.0.16.
Escape character is '^]'.
Connection closed by foreign host.
Any idea what to try?
I had to use VM IP address something like
curl -X GET http://10.0.2.2:3000
These errors may be caused due to follow reasons, ensure the following steps are followed. To connect the local host with the local virtual machine(host). Here, I'am connecting http://localhost:3001/ to the http://abc.test Steps to be followed:
1.We have to allow CORS, placing Access-Control-Allow-Origin: in header of request may not work. Install a google extension which enables a CORS request.*
2.Make sure the credentials you provide in the request are valid.
3.Make sure the vagrant has been provisioned. Try vagrant up --provision this make the localhost connect to db of the homestead.
Try changing the content type of the header. header:{ 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8;application/json' }
this point is very important.

Rails 5 development server - access from the outside

I have an android phone and I need to send some requests to a rails server.
I do the usual stuff by picking up the ip address from ifconfig then using that ip address on port 3000.
It does not work. Even if I run something like wget ip_address:3000 it does not.
Is it because the port 3000 is blocked ?
The Rails server only binds to localhost, you need to use the -b option, eg. rails s -b 0 This will bind to 0.0.0.0 (ie. all addresses). My answer here goes into more detail: https://stackoverflow.com/a/29084070/152786

Setting up Mosquitto on home server

I'm struggling with exposing Mosquitto that I setup on my Centos7 homeserver to the outside internet through my router.
Mosquitto runs fine on my localhost and post 1883 on the homeserver. I am able to pub/sub, and it is listening on the port as 127.0.0.1:1883 (tcp)
My home router has a dynamic IP (for now), say 76.43.150.206. On the router I port forwarded 1883 as both internal/external ports to my home server, say 192.168.1.100.
In the mosquitto.conf file, I have one simply line "listener 1883 76.43.150.206".
When I then attempt to pub/sub using a python client on an external computer as mqttc.connect("76.43.150.206", 1883), it says connection refused.
Any hints on what I'm doing wrong or how to get it working? BTW, my understanding of this setup is very basic and I've pretty much been going off blogs.
Here's how it will work:
1.) Setup mosquitto.conf as
listener 1883 0.0.0.0
#cafile <path to ca file>
#certfile <path to server cert>
#keyfile <path to server key>
#require_certificate false
0.0.0.0 binds the server to all interfaces present.
You can uncomment the code to enable TLS for better security. But you'll have to configure the client to use the same as well..
2.) Port forward router's 1883 port number to port 1883 of IP of machine running the broker.
3.) Start the broker and test your client!
You should not put the external address into the mosquitto config file.
You should probably not even have a listen line at all as mosquitto will bind to all available IP addresses on the machine it's running with the default port (1883).
If you really must use the listen directive (e.g. in order to set up SSL) then it should be configured with the internal IP address of the machine running the broker, in this case 192.168.1.100 and with a different port number so it does not clash with the default
listen 1884 192.168.1.100

Ubuntu server - port forwarding

I need to redirect http port 80 to port with specific page, which running on port 9090/somepage.
So in short:
Need redirect x.x.x.x:80 -> x.x.x.x:9090/page
I tried to do by command iptable, but I not be able to redirect port to specific port and page (only port to another port).
Please how I can realize this?
You probably need an proxypass in the virtualhost to redirect it. For Apache:
https://httpd.apache.org/docs/current/mod/mod_proxy.html

Yaws server is not accessible outside of local network

I am trying to host erlang Yaws web server on my Raspberry Pi.
I am using no-ip as dynamic DNS.
My router is Thomson ST780. On the router I have made port forwarding from port 50001 to port 8081 on my Raspberry Pi.
My server is accessible from within the local network only and shows index.yaws as expected. However, I want it to be accessible from the internet. I believe the problem lies in Yaws config, because I have disabled firewall on my router, and also firewall is disabled on Pi.
The Yaws config part that I believe is wrongly configured looks like this:
<server my_application_name.no-ip.org>
port = 8081
listen = 0.0.0.0
docroot = /home/pi/erl/airport
dir_listing = false
auth_log = true
statistics = true
appmode = <cgi-bin, yaws_appmod_cgi>
</server>
I have also tried adding
<auth> allow = all </auth>
and putting local IP address in listen part and it is still not working.
Can anybody see the problem with this configuration?
I am also using the same way of port forwarding on my router for SSH and SSH is accessible from the internet.
EDIT: The install that I have made is local_install, as recommended here: http://yaws.hyber.org/configuration.yaws and perhaps that might be a problem.

Resources