ZoneMinder behind NGINX

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
Maximo1970
Posts: 97
Joined: Sun May 28, 2017 4:29 pm

ZoneMinder behind NGINX

Post by Maximo1970 »

I have a odd issue but I'm not sure where to look for a resolution, therefore I'm hoping that some of you clever people will offer me some suggestions.

I'm running with a multi server setup, 4 servers in total. Three of the servers handle the Hi-Res camera feeds and the forth looks after all of the Lo-Res cameras feeds. This fourth server is were I proxy to over the Internet via Nginx. Here's my Nginx config.

Code: Select all

server {
        server_name zoneminder.mycyberspace.co.uk;
        server_name zm04.cctv.mycyberspace.co.uk;
        server_name zm03.cctv.mycyberspace.co.uk;
        server_name zm02.cctv.mycyberspace.co.uk;
        server_name zm01.cctv.mycyberspace.co.uk;
        server_name zm04.cctv.mycyberspace.net;
        server_name zm03.cctv.mycyberspace.net;
        server_name zm02.cctv.mycyberspace.net;
        server_name zm01.cctv.mycyberspace.net;

        location / {
                proxy_pass                            http://zm04.cctv.mycyberspace.net;
                proxy_set_header Host                 $http_host;
                proxy_set_header X-Real-IP            $remote_addr;
                proxy_set_header X-Forwarded-For      $proxy_add_x_forwarded_for
;
                proxy_set_header X-Forwarded-Proto    $scheme;
        }
        location /zm/cgi-bin {
        auth_basic off;
                alias /usr/libexec/zoneminder/cgi-bin;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_param HTTP_PROXY "";
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
        location /zm/cache {
                auth_basic off;
                alias /var/cache/zoneminder;
        }
        location ~ /zm/api/(css|img|ico) {
                auth_basic off;
                rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
                try_files $uri $uri/ =404;
        }

        listen 80;
}
No problem with connecting and viewing all of the Lo-Res cameras, however for some reason the browser keeps refreshing. Which causing a bit of frustration and annoyance to say the least. If I browse directly to the fourth server within my LAN there is no browser refresh, so I'm assuming that it's more likely to the a config issue with Nginx. But as I'm sure more people have a similar setup I'm hoping there is a config change I can make to stop the browser keep refreshing.

Thanks in advance.

Garry
Maximo1970
Posts: 97
Joined: Sun May 28, 2017 4:29 pm

[SOLVED] ZoneMinder behind NGINX

Post by Maximo1970 »

After a lot of searching and testing I think I've resolved my issues by adding the following to my config.

Code: Select all

        # kill cache
        add_header Last-Modified $date_gmt;
        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        if_modified_since off;
        expires off;
        etag off;
Post Reply