NGINX Reverse proxy problem accesing video streams

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
chano
Posts: 1
Joined: Thu Sep 12, 2019 11:47 am

NGINX Reverse proxy problem accesing video streams

Post by chano » Thu Sep 12, 2019 12:06 pm

Hi, it might sounds like a extrange config but it makes a little sense form me.

I have an edge machine running Nginx as reverse proxy exposing an SSL connection to the Internet (on a non standard port) that proxies connection to my zoneminder docker which is working on port 80 without SSL.

Everything works fine but camera images. I get a broken link where camera image is supposed to be shown.

Digging in the problem, I realized that the IMG link that zoneminder places was in plain http (no https) and no port was placed.

I've studied the code and I finally found that in the includes path there is a Server.php file that holds two functions called Protocol and Port which mission is provide the correct "Protocol" and "Port" for the URL's.

So, to make things work I've made a couple changes: First, in Nginx I've added this two config lines to include in the HTTP Headers the original protocol and port the request had:

Code: Select all

           proxy_set_header X-Forwarded-Proto $scheme;
           proxy_set_header X-Forwarded-Port $server_port;
Then I've added at the end of Protocol function in Server.php this code:

Code: Select all

$headers = apache_request_headers();

    if (isset($headers['X-Forwarded-Proto'])) {
            return($headers['X-Forwarded-Proto']);
    }
And a very similar change at the end of Port function also in Server.php:

Code: Select all

   $headers = apache_request_headers();

   if (isset($headers['X-Forwarded-Port'])) {
       return($headers['X-Forwarded-Port']);
   }
So now, everything works like a charm!

I post this here in case it can help someone and it will be nice that this little change could be incorporated to the Zoneminder Code.

Thx
Chano.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests