Can I send a URL request in OpenWRT using Lua? - url

I want to initiate a php program on my web server from OpenWRT running on a Linksys router. How can I do this? I don't have room to install elinks.

use busybox wget http://192.168.42.220/index.html

Using Luasocket you can fetch a webpage (and thus triggering your php page) with socket.http.request(url).
That is, if you have luasocket on your OpenWRT.

Related

Serving localhost rails application externally https

I am currently running a rails application on my local machine as the backend api for a hobby web application (have too many sql rows and dont want to pay for it).
I already figured out how to forward my port and access the api through http://[myexternalipaddress]:8080/api/etc.... from the external internet.
This is working fine, but i want to be able to serve this end point through https instead so my users dont get security warnings. I did some research, but I am confused what I need to do next. Is the https serving done via my rails configuration, or some other method?
here is the command I use to start my rails server:
rails s --binding=0.0.0.0 -p 8080
You can use ngrok and expose your local server
on mac you can install it with brew
$ brew cask install ngrok
$ ngrok http 3000
this will give you url like https://xxyyzz.ngrok.io to access it publicly

Create composer-rest-api server

I'm studying hyperledger composer and want to make a simple server and mobile app to interact with it in my local home-network. I have a linux server with docker and without access to the internet. I deploy my network to server and have cards on my computer. Now i want to start rest-api on server.
If you start composer-rest-server on server, it needs cards that i have on my computer. So, i can't start composer-rest-server here. With the docker container hyperledger/composer-rest-server the same problem, it needs cards.
Well, the only solution is to export cards to server? Can i do it without installing composer-cli on server? Maybe there are other solutions?
The composer rest server necessarily needs a business network card in order to generate the REST API. You should import the card into your server.
For more informations see: https://hyperledger.github.io/composer/latest/integrating/deploying-the-rest-server

Can't access my reddit installation

I install Reddit Script on my server but I can't access my installation. I try to access http://129.xxx.xx.xx (my server IP address but is has a redirection to reddit.local and here looks to load for ever.
I install it using my automatic installer and after that I just populate the script with some data as per instruction provided in the bottom of the instruction document.
I miss something?
You'll need to configure the hostname you used (it sounds like reddit.local) to point to the correct place. The easiest method to do this is via an entry in your /etc/hosts.
Does it work if you request from localhost on the server?
The install script is designed for testing (i.e. in a Vagrant VM), not production; if you're trying to set up a production website, you'll probably want to follow the manual install guide.

Connect Nodejs Faye-Client to Rails Faye server

I have a Faye server running under Rails (with redis backend) and would like to allow a nodejs script to communicate with my clients via Faye. Therefore I need to connect my Nodejs Faye client to the Rails process, that runs Faye.
Using:
var client = new faye.Client('http://localhost:6379/faye');
//I also tried ports 3000 and 8000 and verified that redis runs at 6379
faye.Logging.logLevel = 'debug'
faye.logger = function(msg){
console.log(msg)
}
client.connect();
I only see:
[Faye.Client] Initiating handshake with "undefined//undefinedundefined"
[Faye.Dispatcher] Selected
"long-polling" transport for "http://localhost:6379/faye"
[Faye.Client] Passing through "outgoing" extensions:
{"channel":"/meta/handshake","version":"1.0","supportedConnectionTypes":["in-process","websocket","long-polling"],"id":"1"}
Do I really need to start a nodejs-faye-server as well to configure it to use redis, or shouldn't it be enough to have NodeJS acting as a client to Rails? Unfortunately this answer did not help me. Has anybody ever done this? If so, how?
Found the answer. Turned out the problem was not in the NodeJS script, but in the way I started in from Ruby. Turns out that system waits for value to be returned and thus does not process the Faye-message. Using spawn() solved the issue.

What is the safest way to test a local rails server?

I am not very experienced, but I have played around with rails a little in the past. When I did it was easy to test the app without actually exposing anything to the internet, since I could just point my browser to localhost. But this app will be getting input from a cellphone so I think it needs to be exposed. What I did so far was to push it to heroku and test there, but that does not seem like a good solution at all since every time I make a change i have push it. I am thinking I have to open a port on my router so and expose the server, which I think I can figure out how to do fairly quickly. Any suggestions on how to try to keep this as safe as possible? Or is there a better solution that I am missing?
The way you could test it if your server and your cell phone are on the same network is just find the local IP address on your machine running the server. You would then go into the browser of the cell phone and type the IP of your browser 'colon' the port the server is listening to (most likely 3000 if a rails server).
So for example if the servers IP was 192.168.0.1 it would be 192.168.0.1:3000
Since you are doing this on an app just put in 192.168.0.1 for the IP of the connection and 3000 for the port. Or if using a url 192.168.0.1:3000 (just like the browser)
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://192.168.0.1:3000");
A very simple way is to use Pow in combination with xip.io.
The former is a local webserver that will run any Rack application behind the scenes for you.
Installing is as simple as:
$ curl get.pow.cx | sh
and linking your app in:
$ ln -s <path-to-app> ~/.pow/myapp
Your app is now accessible at http://myapp.dev/ locally.
Assuming your computer's IP is 10.0.1.1 and your cell phone is on the same Wifi network, your app will be accessible on the phone from http://myapp.10.0.1.1.xip.io.
Caveat: you'll be getting Wifi performance, not cellular performance.

Resources