Daan Pape
Daan Pape

Reputation: 1140

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

Upvotes: 1

Views: 1401

Answers (1)

Thnesko
Thnesko

Reputation: 108

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:[email protected]/cgi-bin/snapshot.cgi?1

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

Upvotes: 1

Related Questions