Page 1 of 1

Redirect image from the JPEG cam on the private network

Posted: Sun Feb 01, 2009 1:41 pm
by dren
Hi all.

My question is. how to redirect JPEG picture from a device on the private network to the internet network? So I have the following:


JPEG camera <= 172.3.2.1 => eth0 [Debian PC, Apache, PHP] eth1 <=internet user => Web client

Currently, PHP is save that picture to the WWW directory so that www clients can read that. Is there a better and faster way?n

Regards Dre

Re: Redirect image from the JPEG cam on the private network

Posted: Sun Feb 01, 2009 3:53 pm
by infolock
well, if you're just serving up the images on the web for users to view, yeah.. it would make sense to just post them to www. anywhere outside of www is restricted and cannot be accessed via web clients. if it is accessible, you're gonna have more problems than just images: you're gonna have security issues as well.

if this isn't what you mean, please explain a bit more. thanks

Re: Redirect image from the JPEG cam on the private network

Posted: Sun Feb 01, 2009 4:39 pm
by VladSun
So, your JPEG camera has IP 172.3.2.1 in your private network, right?
If it's so then you need:
1. Enable IP packets forwarding:

Code: Select all

sysctl -w net.ipv4.ip_forward="1"

Code: Select all

iptables -P FORWARD DROP
iptables -A FORWARD -i eth0 -s 172.3.2.1 -j ACCEPT
iptables -A FORWARD -i eth1 -d 172.3.2.1 -j ACCEPT
2. Redirect traffic to JPEG camera (port forwarding):

Code: Select all

iptables -t nat -A PREROUTING -i eth1 -p tcp -d your_server_IP_on_eth1 --dport 8089 -j DNAT --to-destination 172.3.2.1
This way anybody who connects (TCP/IP) to your_server_IP_on_eth1:8089 will in fact connect to 172.3.2.1:8089

Re: Redirect image from the JPEG cam on the private network

Posted: Mon Feb 02, 2009 5:27 am
by dren
Hi.

Thanks for your ideas. I think that I have found the solution.

--test.php file
<?php
$cam= "http://172.31.x.x.x/image.esp?photo=1"; //this is the IP address of the JPEG webcam withc returns a JPEG picure each time it is called

$myJpeg = fopen($cam, 'rb');
if ($myJpeg) {
header('Content-Type: image/png');
fpassthru($myJpeg);
}

?>

---webclient.html file

//javascript autorefresh image here using
<img id='img' src='test.php'/>

So my design is so that I have a Debian PC with two network interfaces. One is connected to local network (172.31.x.x) and the other one is conneced to the public (internet) network.
Now the netork firewall can be configured to access only the www server. There is no access to the private network from the internet.