简体   繁体   中英

Reverse proxy to remove digest authentication

I'm already looking for days for a solution but I'm not able to find something. I have a few IP camera's (Dahua) which don't have an option for unauthorized, public so to say, viewing. I'm now looking for a proxy server which can do the following:

  1. Connect to the IP camera stream (MJPEG)
  2. If the camera returns a 401 the proxy must login with a saved username and password
  3. Transmit the IP camera stream

I can accomplish this with nginx by adding the Authorization header but, and this is the difficult part, only when the camera uses Basic authentication.

Some models however only support Digest authentication which is not static.

Can someone point me to some software or nginx/apache plugin which can do this? I'm looking for something like this https://github.com/jantman/python-amcrest-noauth-proxy but written in C so that I can run it on OpenWRT embedded device.

Kind regards, Daan

I used fcgiwrap with curl to do this.

nginx.conf:

server {
    listen 8080;
    root /usr/share/nginx/html;

    location /tmp/ {
        internal;
        alias /tmp/;
    }

    location / {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }
}

screenshot.cgi:

#!/bin/bash

TMPF=$(mktemp /tmp/screenshot_XXXXXXX.jpg)

curl -sL --digest --output $TMPF http://guest:guest@10.100.0.95/cgi-bin/snapshot.cgi?1

echo -e "X-Accel-Redirect: $TMPF"
echo -e ""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM