LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2017, 03:21 AM   #1
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,641

Rep: Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615
what is the right way to redirect/forward/modify


Hi all,
I don't want a solution, I just looking for the right way to implement something which I have never made before and I don't know its name....
It is something like port forwarding, rerouting, redirecting with some spoofing or proxy or ???

So actually I have a web server on a smart home device which can switch lights on/off, regulate temperature, dim lights ...
I have also a smartphone where a google app is installed which is connected to this web server and drives that unit.
What I want is to catch that traffic, and either modify the commands (arriving from phone) or send commands to the unit directly, without the phone.
This unit has an api with a relatively simple syntax (using both get and put), the response is a json "file" and I have a raspberry pi for this. But what is the tool to use (in perl/python/whatever)?
The pi should be seen as the web server from the phone.
 
Old 11-27-2017, 03:38 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,690
Blog Entries: 3

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
I'd lean towards perl for this if you want a custom proxy, for authentication and to sanitize and validate any input on its way to your home device. CPAN modules to look for would be LWP::UserAgent, FCGI, and JSON. You'd needs a small web server for that to set up the FCGI socket that the perl script would then listen to. Requests would be processed and checked, and a JSON object built and passed to the home device inside with an HTTP or HTTPS call.

If you're only worried about authentication then even that might be overly complicated and so Squid might be enough. The main thing that I would worry about is having your home device sufficiently isolated on the LAN so that it only accepts access from the proxy.

Just plain port forwarding from an intermediate machine might be a bad idea if the forwarding proxy does no additiona authentication.

Does your device use HTTPS? Is it using a wired network connection or wifi?
 
Old 11-27-2017, 05:49 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,641

Original Poster
Rep: Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615Reputation: 5615
authentication is not an issue. This is only available on the local net and this web server has no any user/password to check.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect/forward a domain locally nicklaszlo Linux - Networking 2 05-30-2013 02:56 PM
Linux port forward or redirect question. JackL92 Linux - Server 6 06-07-2011 12:31 PM
Redirect / forward mail to another user from specific address. nishith Linux - Server 1 06-30-2009 01:59 PM
iptables forward/redirect: the easy way? efm Linux - Networking 2 01-29-2008 07:59 PM
Iptables redirect AFTER INPUT/FORWARD chain processing tunasashimi Linux - Networking 0 07-09-2007 03:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration