0

The title it self doesn't say a lot, but what I need is...

I have a web page, with a PHP login and some functions in it as well.

I put my raspberry camera stream the with:

<div align="center">
      <img src="http://server.onthewifi.com:8081"/>
</div>

and it works... but anyone could see the camera going to http://server.onthewifi.com:8081 with out login in my PHP login page.

I know there's a login option in motion.conf file, but if I enable it there would be a double login in the server, and it doesn't look good. I don't like the motion login though, I'd prefer to use my custom login, is there a way to do something like that.

I'm not an English speaker, if there's something wrong please tell me, and if there's something you don't understand please tell me.

2 Answers 2

2

Are you looking to only connect to it from a single IP address? As you could simply set a firewall that blocks all outgoing connections from ips that aren't yours. But more realistically what you'd want is for your custom login to authenticate the motion server, this would likely be done by having your custom login server also send a post request via Ajax to the motion server to authenticate both of them simultaneously. Please write a comment on this if you need help setting it up, but s great place to start would be to look up Ajax post request tutorials.

4
  • The idea is that anyone with an account on my web server (which is the raspberry, the same that has the camera) can see the camera. So... they just login in the server and they have access to the camera, but if I do that the camera is open to everybody on server.onthewifi.com:8081, and I just want people who have an account to see the camera. I don't even know if it is possible...
    – gloaiza
    May 19, 2016 at 22:37
  • What you want is to turn on login in motion.conf , then use Ajax from your login page to post the login credentials to the motion server which will generate both cookies needed for both login sessions with only a single login page May 19, 2016 at 23:35
  • Thanks! That's exactly what I need... I don't how to do it though. So.. Ajax post request it is, time for research... thank you!
    – gloaiza
    May 20, 2016 at 0:31
  • Not a problem, please mark this question as answered, if it has helped you solve your problem May 20, 2016 at 0:31
0

While not foolproof (as IP addresses can be spoofed), you could setup a firewall.

Install uncomplicated firewall (UFW):

sudo apt-get install ufw

then add a rule to allow connections only from your subnet:

sudo ufw allow from 192.168.1.0/24  to any port 8081 

change the IP (192.168.1.0) to whatever is appropriate for your network.

A more detailed tutorial on UFW can be found here

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Ghanima
    May 19, 2016 at 22:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.