Yaws server is not accessible outside of local network - erlang

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.

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.

Port Forwarding for compute engine google cloud platform

I'm trying to open port TCP 28016 and UDP 28015 for a game server in my compute engine VM running on Microsoft Windows Server 2016.
I've tried opening the opening inside my server using RDP, going to Windows Firewall setting and creating new inbound rules for both TCP 28016 and UDP 28015.
Also done setting firewall rules on my Cloud Platform Firewall Rules for both port.
When running my game server application, running netstat didn't show any of the port being used / not listening . Not even shows up. What did i do wrong ?
Edit : it now shows up on netstat -a -b , but didn't have LISTENING
If it doesn't show as LISTENING, it's not a firewall or "port forwarding" issue; rather, the application either isn't running, or is running but isn't configured to listen for connections on that port.

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

Ruby Rails callback URL in development

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).

What is the difference between starting a server binding to 0.0.0.0 vs 127.0.0.1?

It seems that Rails and Django can both start up the server binding to an IP, either
0.0.0.0, 127.0.0.1, or 192.168.1.2 <-- the last one is my local IP
are there other choices? It seems that 0.0.0.0 and 192.168.1.2 can let a Virtual PC on the same machine access this website, while 127.0.0.1 cannot.
However, if it is just the same notebook, using localhost:3000 (for Rails), then it doesn't matter. But either case, 0.0.0.0:3000 won't work.
How does it work? What are the meanings of using 0.0.0.0 vs 127.0.0.1 vs 192.168.1.2?
Binding to 0.0.0.0 means to listen to all interfaces.
Binding to 127.0.0.1 means to listen to the loopback interface.
0.0.0.0 binds to all IP addresses. Any other address binds to that particular interface.
If you start the server on 127.0.0.1, it is only listening on localhost; if you start it on 0.0.0.0, it is listening on any IP (eg your local IP).
For local dev, this is fine - but otherwise, no one but the local machine will be able to see it.

Resources